@greatstore/cli 0.1.10 → 0.1.11

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/CHANGELOG.md CHANGED
@@ -3,6 +3,13 @@
3
3
  All notable changes to `@greatstore/cli` are recorded here. The format
4
4
  follows [Keep a Changelog](https://keepachangelog.com/).
5
5
 
6
+ ## 0.1.11 — 2026-09-14
7
+
8
+ ### Added
9
+ - `gs apps rename <old> <new>` renames a component without republishing it:
10
+ its versions and live state carry over, and a local `components/<old>/`
11
+ folder is renamed to match.
12
+
6
13
  ## 0.1.10 — 2026-09-13
7
14
 
8
15
  ### Changed
package/README.md CHANGED
@@ -66,6 +66,7 @@ working.
66
66
  | `gs apps push [<name>] [--manifest path] [--bundle path]` | Upload local changes. |
67
67
  | `gs apps publish <name> [--version N]` | Ship a component (optionally a previous version). |
68
68
  | `gs apps unpublish <name>` | Hide a published component. |
69
+ | `gs apps rename <old> <new>` | Rename a component, keeping its versions and live state. |
69
70
  | `gs apps delete <name> [--yes]` | Remove the component. |
70
71
 
71
72
  ### Component checks
package/dist/cli.js CHANGED
@@ -1,41 +1,41 @@
1
1
  #!/usr/bin/env node
2
- var kn={h:"help",v:"version",o:"out"};function Be(e){let t={command:null,positional:[],flags:{}};if(e.length===0)return t;let n=0,r=e[0];for(r&&!r.startsWith("-")&&(t.command=r,n=1);n<e.length;n++){let o=e[n]??"";if(o.startsWith("--")){let s=o.indexOf("="),i,a;if(s!==-1)i=o.slice(2,s),a=o.slice(s+1);else{i=o.slice(2);let l=e[n+1];l===void 0||l.startsWith("--")||l.startsWith("-")?a=!0:(a=l,n++)}i&&(t.flags[i]=a)}else if(o.startsWith("-")&&o.length>1){let s=o.slice(1),i=kn[s];if(!i)continue;let a=e[n+1];a===void 0||a.startsWith("-")?t.flags[i]=!0:(t.flags[i]=a,n++)}else t.positional.push(o)}return t}function h(e,t){let n=e[t];return typeof n=="string"?n:void 0}function m(e,t){let n=e[t];return n===!0||n==="true"}import*as Ue from"crypto";import*as Ge from"http";import{spawn as He}from"child_process";var Pn="/callback",Cn='<svg width="40" height="40" viewBox="0 0 82 82" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path transform="scale(0.8) translate(7, 4)" d="M13 70.7522C13 70.7522 1.5 68.7522 1.5 57.7522C1.5 46.7522 23 48.2522 23 48.2522L80 47.2522C80 47.2522 91.5938 45.7522 91 36.2522C90.4062 26.7522 77 26.7522 77 26.7522H51C51 26.7522 44.5 27.6967 40.5 23.2522C36.5 18.8078 39 11.7522 44.5 7.25221C50 2.75222 52.5 0.752227 58 1.75223C63.5 2.75223 67.5 7.25221 65 14.2522C62.5 21.2522 32.5 74.7522 32.5 74.7522C32.5 74.7522 27.5 87.7522 36.5 90.7522C45.5 93.7522 49.5 86.2522 49.5 86.2522C49.5 86.2522 64 61.7522 66 58.7522C68 55.7522 72 52.4522 78 54.2522C84 56.0522 85.5 67.7522 85.5 69.7522C85.5 71.7522 85.5 82.2522 78 83.2522C70.5 84.2522 67.5 79.7522 66.5 78.7522C65.5 77.7522 31 20.7522 30 19.7522C29 18.7522 22 11.7522 16 15.7522C10 19.7522 12.5 27.2522 13 28.7522C13.5 30.2522 28 56.2522 29 58.7522C30 61.2522 31.5 66.7522 27 70.2522C22.5 73.7522 13 70.7522 13 70.7522Z" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></svg>',$n=`:root{color-scheme:light}
2
+ var Cn={h:"help",v:"version",o:"out"};function Me(e){let t={command:null,positional:[],flags:{}};if(e.length===0)return t;let n=0,r=e[0];for(r&&!r.startsWith("-")&&(t.command=r,n=1);n<e.length;n++){let o=e[n]??"";if(o.startsWith("--")){let s=o.indexOf("="),i,a;if(s!==-1)i=o.slice(2,s),a=o.slice(s+1);else{i=o.slice(2);let l=e[n+1];l===void 0||l.startsWith("--")||l.startsWith("-")?a=!0:(a=l,n++)}i&&(t.flags[i]=a)}else if(o.startsWith("-")&&o.length>1){let s=o.slice(1),i=Cn[s];if(!i)continue;let a=e[n+1];a===void 0||a.startsWith("-")?t.flags[i]=!0:(t.flags[i]=a,n++)}else t.positional.push(o)}return t}function h(e,t){let n=e[t];return typeof n=="string"?n:void 0}function m(e,t){let n=e[t];return n===!0||n==="true"}import*as qe from"crypto";import*as Ve from"http";import{spawn as Ue}from"child_process";var En="/callback",An='<svg width="40" height="40" viewBox="0 0 82 82" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path transform="scale(0.8) translate(7, 4)" d="M13 70.7522C13 70.7522 1.5 68.7522 1.5 57.7522C1.5 46.7522 23 48.2522 23 48.2522L80 47.2522C80 47.2522 91.5938 45.7522 91 36.2522C90.4062 26.7522 77 26.7522 77 26.7522H51C51 26.7522 44.5 27.6967 40.5 23.2522C36.5 18.8078 39 11.7522 44.5 7.25221C50 2.75222 52.5 0.752227 58 1.75223C63.5 2.75223 67.5 7.25221 65 14.2522C62.5 21.2522 32.5 74.7522 32.5 74.7522C32.5 74.7522 27.5 87.7522 36.5 90.7522C45.5 93.7522 49.5 86.2522 49.5 86.2522C49.5 86.2522 64 61.7522 66 58.7522C68 55.7522 72 52.4522 78 54.2522C84 56.0522 85.5 67.7522 85.5 69.7522C85.5 71.7522 85.5 82.2522 78 83.2522C70.5 84.2522 67.5 79.7522 66.5 78.7522C65.5 77.7522 31 20.7522 30 19.7522C29 18.7522 22 11.7522 16 15.7522C10 19.7522 12.5 27.2522 13 28.7522C13.5 30.2522 28 56.2522 29 58.7522C30 61.2522 31.5 66.7522 27 70.2522C22.5 73.7522 13 70.7522 13 70.7522Z" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></svg>',jn=`:root{color-scheme:light}
3
3
  body{font-family:"Instrument Sans",ui-sans-serif,system-ui,sans-serif;font-size:15px;line-height:1.6;margin:0;padding:4rem 1.5rem;max-width:26rem;margin-inline:auto;color:#091717;background:#fcfaf6;text-align:center}
4
4
  .logo{color:#091717;margin-bottom:1.5rem}
5
5
  h1{font-family:"Instrument Serif",ui-serif,Georgia,serif;font-style:italic;font-weight:400;font-size:1.75rem;margin:0 0 .5rem}
6
- p{color:#2c3a38}`,En=`<!doctype html>
6
+ p{color:#2c3a38}`,Rn=`<!doctype html>
7
7
  <html lang="en"><head><meta charset="utf-8"><title>GreatStore CLI</title>
8
8
  <link rel="preconnect" href="https://fonts.googleapis.com">
9
9
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
10
10
  <link href="https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;500;600;700&family=Instrument+Serif:ital@1&display=swap" rel="stylesheet">
11
- <style>${$n}</style></head>
11
+ <style>${jn}</style></head>
12
12
  <body>
13
- <div class="logo">${Cn}</div>
13
+ <div class="logo">${An}</div>
14
14
  <h1>You're signed in.</h1>
15
15
  <p>This window will close automatically. If it doesn't, you can close it and return to your terminal.</p>
16
16
  <script>setTimeout(function(){window.close();},250);</script>
17
- </body></html>`,Me=`<!doctype html>
17
+ </body></html>`,Ge=`<!doctype html>
18
18
  <html lang="en"><head><meta charset="utf-8"><title>GreatStore CLI</title>
19
19
  <style>body{font:14px/1.5 system-ui;margin:4rem auto;max-width:32rem;color:#222;text-align:center}
20
20
  h1{font-size:1.4rem;color:#a40000}code{background:#f4f4f4;padding:.1em .3em;border-radius:.2em}</style></head>
21
21
  <body><h1>Sign-in failed.</h1>
22
- <p>Return to your terminal for details.</p></body></html>`,V=class extends Error{constructor(t){super(t),this.name="LoopbackError"}};async function fe(e){let t=(e.generateState??jn)(),n=e.timeoutMs??300*1e3,r=e.openBrowser??(s=>Rn(s,e.browserCmdEnv)),o=Ge.createServer();try{await new Promise(c=>o.listen(0,"127.0.0.1",c));let s=o.address(),i=new URL(`${e.dashboardBaseUrl}/cli/authorize`);i.searchParams.set("port",String(s.port)),i.searchParams.set("state",t),e.requestedStore&&i.searchParams.set("store",e.requestedStore);let a=i.toString(),l=An(o,t,n);return r(a),await l}finally{o.close()}}function An(e,t,n){return new Promise((r,o)=>{let s=!1,i=l=>{s||(s=!0,l())},a=setTimeout(()=>{i(()=>o(new V("Sign-in timed out. Re-run `gs login`.")))},n);typeof a.unref=="function"&&a.unref(),e.on("request",(l,c)=>{let p=new URL(l.url??"/","http://127.0.0.1");if(p.pathname!==Pn){c.writeHead(404,{"content-type":"text/plain"}),c.end("Not found");return}let u=p.searchParams,f=u.get("error"),j=u.get("error_description"),k=u.get("code");if(u.get("state")!==t){c.writeHead(400,{"content-type":"text/html"}),c.end(Me),clearTimeout(a),i(()=>o(new V("Sign-in didn't complete. Please try again.")));return}if(f||!k){c.writeHead(400,{"content-type":"text/html"}),c.end(Me),clearTimeout(a),i(()=>o(new V(j??"Sign-in failed. Please try again.")));return}c.writeHead(200,{"content-type":"text/html"}),c.end(En),clearTimeout(a);let R=u.get("store")?.trim();i(()=>r(R?{token:k,store:R}:{token:k}))})})}function jn(){return Ue.randomBytes(16).toString("hex")}function Rn(e,t){let r=t?.trim()??_n();if(r)try{let o;if(r==="start"){let s=`start "" "${e}"`;o=He("cmd.exe",["/d","/s","/c",s],{stdio:"ignore",detached:!0,windowsVerbatimArguments:!0})}else o=He(r,[e],{stdio:"ignore",detached:!0});o.on("error",()=>{}),o.unref()}catch{}}function _n(){switch(process.platform){case"darwin":return"open";case"win32":return"start";case"linux":return"xdg-open";default:return null}}import*as P from"fs";import*as z from"os";import*as je from"path";var Tn=".greatstore",Ln="credentials.json";function qe(e=z.homedir()){return je.join(e,Tn)}function Re(e=z.homedir()){return je.join(qe(e),Ln)}function _(e=z.homedir()){let t=Re(e),n;try{let r=P.statSync(t);if(process.platform!=="win32"){let o=r.mode&511;if(o&63)throw new Error(`Refusing to read ${t}: permissions are ${o.toString(8)} (should be 600). Run \`chmod 600 ${t}\`.`)}n=P.readFileSync(t,"utf8")}catch(r){if(On(r))return null;throw r}try{let r=JSON.parse(n);return typeof r.access_token!="string"?null:r}catch{return null}}function de(e,t=z.homedir()){let n=qe(t);if(P.mkdirSync(n,{recursive:!0,mode:448}),process.platform!=="win32")try{P.chmodSync(n,448)}catch{}let r=Re(t);P.writeFileSync(r,`${JSON.stringify(e,null,2)}
23
- `,{mode:384}),process.platform!=="win32"&&P.chmodSync(r,384)}function Ve(e=z.homedir()){P.rmSync(Re(e),{force:!0})}function Ke(e){let t=e.split(".");if(t.length!==3)throw new Error("Invalid JWT: expected three dot-separated segments");let n=t[1];if(!n)throw new Error("Invalid JWT: empty payload segment");let o=(n+"=".repeat((4-n.length%4)%4)).replace(/-/g,"+").replace(/_/g,"/"),s=Buffer.from(o,"base64").toString("utf8");return JSON.parse(s)}function me(e,t=Math.floor(Date.now()/1e3)){return e.expires_at<=t}function On(e){return typeof e=="object"&&e!==null&&e.code==="ENOENT"}var F="0.1.10";var N=class extends Error{constructor(n,r,o){super(r);this.status=n;this.code=o;this.name="HttpError"}},L=class extends Error{constructor(t="Sign in first. Run `gs login`."){super(t),this.name="AuthRequiredError"}};function In(e){let t;try{t=new URL(e)}catch{return}let n=t.pathname.split("/").filter(Boolean);if(n[1]==="admin"&&n[0])return n[0];let r=t.hostname.split(".")[0],o=new Set(["my","www","app","api","admin","localhost"]);if(t.hostname.includes(".")&&r&&!o.has(r))return r}function Fn(e){let t=In(e)??_()?.store;return t?`gs login --store ${t}`:"gs login"}async function d(e,t={}){let n=()=>`Run \`${Fn(e)}\`.`,r=_();if(!r)throw new L(`Sign in first. ${n()}`);if(me(r))throw new L(`Session expired. ${n()}`);try{return await Nn(e,t,r.access_token)}catch(o){throw o instanceof N&&o.status===401?new L(`Session expired. ${n()}`):o}}async function Nn(e,t,n){let r={accept:"application/json",authorization:`Bearer ${n}`,"x-gs-cli-version":F,...t.headers??{}},o;if(t.multipart&&t.body!==void 0)throw new Error("request(): pass either `body` or `multipart`, not both");t.multipart?(o=t.multipart,delete r["content-type"]):t.body!==void 0&&(o=JSON.stringify(t.body),r["content-type"]="application/json");let s={method:t.method??"GET",headers:r};o!==void 0&&(s.body=o);let i=await fetch(e,s);if(i.status>=200&&i.status<300)return i.status===204?void 0:(i.headers.get("content-type")??"").includes("application/json")?await i.json():await i.text();let a=await i.text(),l={};try{l=JSON.parse(a)}catch{}let c=l.code??l.error,p=t.validationDetail&&i.status===400&&l.error?l.error:Dn(i.status,c,l.detail);throw new N(i.status,p,l.code??l.error)}var ze=`This version of the GreatStore CLI is no longer supported.
22
+ <p>Return to your terminal for details.</p></body></html>`,K=class extends Error{constructor(t){super(t),this.name="LoopbackError"}};async function me(e){let t=(e.generateState??Tn)(),n=e.timeoutMs??300*1e3,r=e.openBrowser??(s=>Ln(s,e.browserCmdEnv)),o=Ve.createServer();try{await new Promise(c=>o.listen(0,"127.0.0.1",c));let s=o.address(),i=new URL(`${e.dashboardBaseUrl}/cli/authorize`);i.searchParams.set("port",String(s.port)),i.searchParams.set("state",t),e.requestedStore&&i.searchParams.set("store",e.requestedStore);let a=i.toString(),l=_n(o,t,n);return r(a),await l}finally{o.close()}}function _n(e,t,n){return new Promise((r,o)=>{let s=!1,i=l=>{s||(s=!0,l())},a=setTimeout(()=>{i(()=>o(new K("Sign-in timed out. Re-run `gs login`.")))},n);typeof a.unref=="function"&&a.unref(),e.on("request",(l,c)=>{let p=new URL(l.url??"/","http://127.0.0.1");if(p.pathname!==En){c.writeHead(404,{"content-type":"text/plain"}),c.end("Not found");return}let u=p.searchParams,f=u.get("error"),j=u.get("error_description"),P=u.get("code");if(u.get("state")!==t){c.writeHead(400,{"content-type":"text/html"}),c.end(Ge),clearTimeout(a),i(()=>o(new K("Sign-in didn't complete. Please try again.")));return}if(f||!P){c.writeHead(400,{"content-type":"text/html"}),c.end(Ge),clearTimeout(a),i(()=>o(new K(j??"Sign-in failed. Please try again.")));return}c.writeHead(200,{"content-type":"text/html"}),c.end(Rn),clearTimeout(a);let R=u.get("store")?.trim();i(()=>r(R?{token:P,store:R}:{token:P}))})})}function Tn(){return qe.randomBytes(16).toString("hex")}function Ln(e,t){let r=t?.trim()??On();if(r)try{let o;if(r==="start"){let s=`start "" "${e}"`;o=Ue("cmd.exe",["/d","/s","/c",s],{stdio:"ignore",detached:!0,windowsVerbatimArguments:!0})}else o=Ue(r,[e],{stdio:"ignore",detached:!0});o.on("error",()=>{}),o.unref()}catch{}}function On(){switch(process.platform){case"darwin":return"open";case"win32":return"start";case"linux":return"xdg-open";default:return null}}import*as C from"fs";import*as Q from"os";import*as _e from"path";var In=".greatstore",Fn="credentials.json";function Je(e=Q.homedir()){return _e.join(e,In)}function Te(e=Q.homedir()){return _e.join(Je(e),Fn)}function _(e=Q.homedir()){let t=Te(e),n;try{let r=C.statSync(t);if(process.platform!=="win32"){let o=r.mode&511;if(o&63)throw new Error(`Refusing to read ${t}: permissions are ${o.toString(8)} (should be 600). Run \`chmod 600 ${t}\`.`)}n=C.readFileSync(t,"utf8")}catch(r){if(Nn(r))return null;throw r}try{let r=JSON.parse(n);return typeof r.access_token!="string"?null:r}catch{return null}}function ge(e,t=Q.homedir()){let n=Je(t);if(C.mkdirSync(n,{recursive:!0,mode:448}),process.platform!=="win32")try{C.chmodSync(n,448)}catch{}let r=Te(t);C.writeFileSync(r,`${JSON.stringify(e,null,2)}
23
+ `,{mode:384}),process.platform!=="win32"&&C.chmodSync(r,384)}function Ke(e=Q.homedir()){C.rmSync(Te(e),{force:!0})}function We(e){let t=e.split(".");if(t.length!==3)throw new Error("Invalid JWT: expected three dot-separated segments");let n=t[1];if(!n)throw new Error("Invalid JWT: empty payload segment");let o=(n+"=".repeat((4-n.length%4)%4)).replace(/-/g,"+").replace(/_/g,"/"),s=Buffer.from(o,"base64").toString("utf8");return JSON.parse(s)}function he(e,t=Math.floor(Date.now()/1e3)){return e.expires_at<=t}function Nn(e){return typeof e=="object"&&e!==null&&e.code==="ENOENT"}var N="0.1.11";var D=class extends Error{constructor(n,r,o){super(r);this.status=n;this.code=o;this.name="HttpError"}},O=class extends Error{constructor(t="Sign in first. Run `gs login`."){super(t),this.name="AuthRequiredError"}};function Dn(e){let t;try{t=new URL(e)}catch{return}let n=t.pathname.split("/").filter(Boolean);if(n[1]==="admin"&&n[0])return n[0];let r=t.hostname.split(".")[0],o=new Set(["my","www","app","api","admin","localhost"]);if(t.hostname.includes(".")&&r&&!o.has(r))return r}function Bn(e){let t=Dn(e)??_()?.store;return t?`gs login --store ${t}`:"gs login"}async function d(e,t={}){let n=()=>`Run \`${Bn(e)}\`.`,r=_();if(!r)throw new O(`Sign in first. ${n()}`);if(he(r))throw new O(`Session expired. ${n()}`);try{return await Hn(e,t,r.access_token)}catch(o){throw o instanceof D&&o.status===401?new O(`Session expired. ${n()}`):o}}async function Hn(e,t,n){let r={accept:"application/json",authorization:`Bearer ${n}`,"x-gs-cli-version":N,...t.headers??{}},o;if(t.multipart&&t.body!==void 0)throw new Error("request(): pass either `body` or `multipart`, not both");t.multipart?(o=t.multipart,delete r["content-type"]):t.body!==void 0&&(o=JSON.stringify(t.body),r["content-type"]="application/json");let s={method:t.method??"GET",headers:r};o!==void 0&&(s.body=o);let i=await fetch(e,s);if(i.status>=200&&i.status<300)return i.status===204?void 0:(i.headers.get("content-type")??"").includes("application/json")?await i.json():await i.text();let a=await i.text(),l={};try{l=JSON.parse(a)}catch{}let c=l.code??l.error,p=t.validationDetail&&i.status===400&&l.error?l.error:Mn(i.status,c,l.detail);throw new D(i.status,p,l.code??l.error)}var Ye=`This version of the GreatStore CLI is no longer supported.
24
24
 
25
25
  npm install -g @greatstore/cli@latest
26
- `,We={cli_upgrade_required:{message:ze},INVALID_NAME:{message:"Invalid component name. Use lowercase letters, digits, and underscores, starting with a letter."},not_found:{message:"Component not found on the server."},concurrent_write:{message:"Another change landed before this one. Run `gs apps pull` and try again."},stale_base:{message:"The store has moved past the version this copy was taken from. Run `gs apps pull` first, or push again with --force to overwrite it.",includeDetail:!0},name_mismatch:{message:"Manifest `name` does not match the component folder name.",includeDetail:!0},manifest_invalid:{message:"manifest.json is invalid.",includeDetail:!0},bundle_too_large:{message:"bundle.js is too large."},bundle_not_module:{message:"bundle.js is not a valid ES module."},source_too_large:{message:"component.tsx is too large."}};function Dn(e,t,n){if(t&&t in We){let r=We[t];return r?r.includeDetail&&n?`${r.message} (${n})`:r.message:Je(e)}return Je(e)}function Je(e){return e===401?"Sign-in needed. Run `gs login`.":e===426?ze:e===403?"Not authorized for this component or store.":e===404?"Not found.":e===409?"Conflict \u2014 refresh and try again.":e===413?"Upload too large.":e===429?"Too many requests \u2014 wait a moment and retry.":e>=500?"Server error \u2014 try again shortly.":e>=400?"Request rejected.":"Unexpected response."}function he(e,t){let n=Ke(e),r=Xe(n,"sub");if(!r)throw new Error("Token is missing a `sub` claim.");let o=Bn(n,"exp");return{access_token:e,expires_at:o??Math.floor(Date.now()/1e3)+3600,sub:r,...ge(n,"email","email"),...ge(n,"accountId","accountId"),...ge(n,"name","name"),...ge(n,"surname","surname"),...Hn(n,"superUser","superUser"),...t?{store:t}:{}}}function Xe(e,t){let n=e[t];return typeof n=="string"?n:void 0}function Bn(e,t){let n=e[t];return typeof n=="number"&&Number.isFinite(n)?n:void 0}function ge(e,t,n){let r=Xe(e,t);return r?{[n]:r}:{}}function Hn(e,t,n){let r=e[t];return r===!0?{[n]:!0}:typeof r=="string"&&r.toLowerCase()==="true"?{[n]:!0}:{}}import*as ye from"fs";import*as B from"path";var Mn="https://my.greatstore.ai",D=class extends Error{constructor(t){super(t),this.name="StoreResolutionError"}};function E(e={}){let t=_e(e.cwd??process.cwd());if(t)return Y(t);throw new D("No .gsrc found in this directory or any ancestor. Run `gs apps init --store <slug>` first to scaffold a GreatStore project.")}function Ye(e=process.cwd()){let t=_e(e);if(t)return Y(t);let n=oe();if(n)return n;throw new D("No store selected. Run `gs login`, or run from a project with a .gsrc.")}function oe(){try{return _()?.store??null}catch{return null}}function Y(e){let t=oe();if(t&&t!==e)throw new D(`This targets store "${e}" but you're signed in to "${t}". Run \`gs switch ${e}\` to change stores.`);return e}function _e(e){let t=B.resolve(e),n=B.parse(t).root;for(;;){let r=B.join(t,".gsrc");if(ye.existsSync(r))try{let s=ye.readFileSync(r,"utf8"),i=JSON.parse(s);if(typeof i.store=="string"&&i.store.trim())return i.store.trim()}catch{}if(t===n)return null;let o=B.dirname(t);if(o===t)return null;t=o}}function y(e){let t=h(e.flags,"store")?.trim();if(t)return Y(t);let n=_e(process.cwd());if(n)return Y(n);let r=oe();if(r)return r;throw new D("No store selected. Pass --store <slug>, or run from a project with a .gsrc.")}function C(e,t=process.env){let n=t.GS_API_BASE?.trim();return n?Qe(n):`https://${e}.greatstore.ai`}function se(e=process.env){let t=e.GS_DASHBOARD_BASE?.trim();return t?Qe(t):Mn}function b(e,t=process.env){return`${se(t)}/${e}/admin`}function Qe(e){return e.endsWith("/")?e.slice(0,-1):e}async function Ze(e){let t=h(e.flags,"store")?.trim();process.stdout.write(`Opening browser for sign-in\u2026
27
- `);let{token:n,store:r}=await fe({dashboardBaseUrl:se(),...t?{requestedStore:t}:{}}),o=he(n,r);de(o);let s=o.email??o.sub;o.store?process.stdout.write(`Logged in as ${s}, working on store "${o.store}".
26
+ `,ze={cli_upgrade_required:{message:Ye},INVALID_NAME:{message:"Invalid component name. Use lowercase letters, digits, and underscores, starting with a letter."},not_found:{message:"Component not found on the server."},concurrent_write:{message:"Another change landed before this one. Run `gs apps pull` and try again."},stale_base:{message:"The store has moved past the version this copy was taken from. Run `gs apps pull` first, or push again with --force to overwrite it.",includeDetail:!0},name_taken:{message:"Another component in this store already has that name."},name_mismatch:{message:"Manifest `name` does not match the component folder name.",includeDetail:!0},manifest_invalid:{message:"manifest.json is invalid.",includeDetail:!0},bundle_too_large:{message:"bundle.js is too large."},bundle_not_module:{message:"bundle.js is not a valid ES module."},source_too_large:{message:"component.tsx is too large."}};function Mn(e,t,n){if(t&&t in ze){let r=ze[t];return r?r.includeDetail&&n?`${r.message} (${n})`:r.message:Xe(e)}return Xe(e)}function Xe(e){return e===401?"Sign-in needed. Run `gs login`.":e===426?Ye:e===403?"Not authorized for this component or store.":e===404?"Not found.":e===409?"Conflict \u2014 refresh and try again.":e===413?"Upload too large.":e===429?"Too many requests \u2014 wait a moment and retry.":e>=500?"Server error \u2014 try again shortly.":e>=400?"Request rejected.":"Unexpected response."}function we(e,t){let n=We(e),r=Qe(n,"sub");if(!r)throw new Error("Token is missing a `sub` claim.");let o=Un(n,"exp");return{access_token:e,expires_at:o??Math.floor(Date.now()/1e3)+3600,sub:r,...ye(n,"email","email"),...ye(n,"accountId","accountId"),...ye(n,"name","name"),...ye(n,"surname","surname"),...Gn(n,"superUser","superUser"),...t?{store:t}:{}}}function Qe(e,t){let n=e[t];return typeof n=="string"?n:void 0}function Un(e,t){let n=e[t];return typeof n=="number"&&Number.isFinite(n)?n:void 0}function ye(e,t,n){let r=Qe(e,t);return r?{[n]:r}:{}}function Gn(e,t,n){let r=e[t];return r===!0?{[n]:!0}:typeof r=="string"&&r.toLowerCase()==="true"?{[n]:!0}:{}}import*as Se from"fs";import*as H from"path";var qn="https://my.greatstore.ai",B=class extends Error{constructor(t){super(t),this.name="StoreResolutionError"}};function $(e={}){let t=Le(e.cwd??process.cwd());if(t)return ee(t);throw new B("No .gsrc found in this directory or any ancestor. Run `gs apps init --store <slug>` first to scaffold a GreatStore project.")}function Ze(e=process.cwd()){let t=Le(e);if(t)return ee(t);let n=ce();if(n)return n;throw new B("No store selected. Run `gs login`, or run from a project with a .gsrc.")}function ce(){try{return _()?.store??null}catch{return null}}function ee(e){let t=ce();if(t&&t!==e)throw new B(`This targets store "${e}" but you're signed in to "${t}". Run \`gs switch ${e}\` to change stores.`);return e}function Le(e){let t=H.resolve(e),n=H.parse(t).root;for(;;){let r=H.join(t,".gsrc");if(Se.existsSync(r))try{let s=Se.readFileSync(r,"utf8"),i=JSON.parse(s);if(typeof i.store=="string"&&i.store.trim())return i.store.trim()}catch{}if(t===n)return null;let o=H.dirname(t);if(o===t)return null;t=o}}function y(e){let t=h(e.flags,"store")?.trim();if(t)return ee(t);let n=Le(process.cwd());if(n)return ee(n);let r=ce();if(r)return r;throw new B("No store selected. Pass --store <slug>, or run from a project with a .gsrc.")}function x(e,t=process.env){let n=t.GS_API_BASE?.trim();return n?et(n):`https://${e}.greatstore.ai`}function le(e=process.env){let t=e.GS_DASHBOARD_BASE?.trim();return t?et(t):qn}function S(e,t=process.env){return`${le(t)}/${e}/admin`}function et(e){return e.endsWith("/")?e.slice(0,-1):e}async function tt(e){let t=h(e.flags,"store")?.trim();process.stdout.write(`Opening browser for sign-in\u2026
27
+ `);let{token:n,store:r}=await me({dashboardBaseUrl:le(),...t?{requestedStore:t}:{}}),o=we(n,r);ge(o);let s=o.email??o.sub;o.store?process.stdout.write(`Logged in as ${s}, working on store "${o.store}".
28
28
  `):process.stdout.write(`Logged in as ${s}.
29
- `)}function et(){let e=_()!==null;Ve(),process.stdout.write(e?`Logged out.
29
+ `)}function nt(){let e=_()!==null;Ke(),process.stdout.write(e?`Logged out.
30
30
  `:`Not logged in.
31
- `)}function tt(){let e=_();if(!e)return process.stderr.write("Not logged in. Run `gs login`.\n"),1;let t=me(e),n=[`sub: ${e.sub}`,`email: ${e.email??"(none)"}`,`accountId: ${e.accountId??"(none)"}`,`superUser: ${e.superUser??!1}`,`store: ${e.store??"(none \u2014 run `gs switch`)"}`,`name: ${[e.name,e.surname].filter(Boolean).join(" ")||"(none)"}`,`expires: ${new Date(e.expires_at*1e3).toISOString()}${t?" (EXPIRED)":""}`];return process.stdout.write(n.join(`
31
+ `)}function rt(){let e=_();if(!e)return process.stderr.write("Not logged in. Run `gs login`.\n"),1;let t=he(e),n=[`sub: ${e.sub}`,`email: ${e.email??"(none)"}`,`accountId: ${e.accountId??"(none)"}`,`superUser: ${e.superUser??!1}`,`store: ${e.store??"(none \u2014 run `gs switch`)"}`,`name: ${[e.name,e.surname].filter(Boolean).join(" ")||"(none)"}`,`expires: ${new Date(e.expires_at*1e3).toISOString()}${t?" (EXPIRED)":""}`];return process.stdout.write(n.join(`
32
32
  `)+`
33
- `),t?1:0}async function nt(e){if(!_())throw new L;let n=e[0]?.trim();process.stdout.write(`Opening browser to switch stores\u2026
34
- `);let{token:r,store:o}=await fe({dashboardBaseUrl:se(),...n?{requestedStore:n}:{}}),s=he(r,o);return de(s),s.store?process.stdout.write(`Now working on store "${s.store}".
33
+ `),t?1:0}async function ot(e){if(!_())throw new O;let n=e[0]?.trim();process.stdout.write(`Opening browser to switch stores\u2026
34
+ `);let{token:r,store:o}=await me({dashboardBaseUrl:le(),...n?{requestedStore:n}:{}}),s=we(r,o);return ge(s),s.store?process.stdout.write(`Now working on store "${s.store}".
35
35
  `):process.stdout.write(`Switched.
36
- `),0}import*as st from"fs";import*as it from"os";import*as Q from"path";import{existsSync as Un}from"fs";import*as we from"path";import{fileURLToPath as Gn}from"url";var ie="greatstore";function rt(){for(let e of["./gs-skill/","../../gs-skill/"]){let t=we.resolve(Gn(new URL(e,import.meta.url)));if(Un(we.join(t,"SKILL.md")))return t}throw new Error("internal: this install of the CLI is missing the agent skill files")}function at(){process.stdout.write(qn(rt()))}function qn(e){if(Vn(e))throw new Error(["This copy of the CLI is running from a temporary cache, so the agent","skill has no stable location to install from. Install the CLI first,","then ask again:",""," npm install -g @greatstore/cli"," gs skill"].join(`
37
- `));return["GreatStore agent skill \u2014 installation instructions for an AI coding agent.","","Skill source on this machine:",` ${e}`,"",`Symlink that folder into your skills directory as "${ie}":`,""," mkdir -p <SKILLS_DIR>",` ln -sfn "${e}" "<SKILLS_DIR>/${ie}"`,"","Symlink it, do not copy it: the link keeps the skill current every","time @greatstore/cli is upgraded, with nothing to re-run.","","<SKILLS_DIR> is wherever you load skills from \u2014 for Claude Code that","is ~/.claude/skills for every project, or ./.claude/skills for this","one. Use your own location if it differs, and create it if missing.",`Then read <SKILLS_DIR>/${ie}/SKILL.md to confirm the install.`,"",`On Windows: mklink /D "<SKILLS_DIR>\\${ie}" "${e}"`,""].join(`
38
- `)}function Vn(e){let t=e.split(Q.sep).join("/");if(/\/(?:_npx|_cacache|\.bun\/install\/cache)\//.test(t)||/\/(?:dlx-|bunx-|\.npx-)/.test(t))return!0;let n=it.tmpdir();return ot(e,n)||ot(e,Kn(n))}function ot(e,t){let n=Q.relative(t,e);return n!==""&&!n.startsWith("..")&&!Q.isAbsolute(n)}function Kn(e){try{return st.realpathSync(e)}catch{return e}}var H={mode:{kind:"string",values:["auto","light","dark","custom"],help:"Color scheme. `auto` follows the shopper's system preference.",brandVisible:!0},radius:{kind:"string",values:["sharp","default","rounded"],help:"Corner rounding preset applied to every surface.",brandVisible:!0},panelPosition:{kind:"string",values:["left","right","middle"],help:"Where the chat panel sits on desktop.",brandVisible:!0},fontFamily:{kind:"string",help:"Primary font family name.",brandVisible:!0},secondaryFontFamily:{kind:"string",help:"Font family for the assistant's chat bubbles.",brandVisible:!0},mobileBottomBar:{kind:"boolean",help:"Show the compact bottom bar on mobile.",brandVisible:!0},zIndex:{kind:"integer",help:"Stacking order of the chat panel on the host page."},brandColor:{kind:"color",help:"Accent color.",brandVisible:!0},surfaceColor:{kind:"color",help:"Background color.",brandVisible:!0},textColor:{kind:"color",help:"Text color.",brandVisible:!0},surface:{kind:"color",help:"Panel background."},surfaceSecondary:{kind:"color",help:"Secondary background."},surfaceAccent:{kind:"color",help:"Accented background."},surfaceHover:{kind:"color",help:"Hovered background."},foreground:{kind:"color",help:"Body text."},foregroundSecondary:{kind:"color",help:"Secondary text."},foregroundMuted:{kind:"color",help:"Muted text."},foregroundAccent:{kind:"color",help:"Accented text."},border:{kind:"color",help:"Border color."},borderFocus:{kind:"color",help:"Focus-ring color."},primary:{kind:"color",help:"Primary button background."},primaryForeground:{kind:"color",help:"Primary button text."},primaryHover:{kind:"color",help:"Primary button hover."},primaryMuted:{kind:"color",help:"Muted primary background."},primaryMutedForeground:{kind:"color",help:"Muted primary text."},primaryTint:{kind:"color",help:"Primary tint wash."},link:{kind:"color",help:"Link color."}};function ct(e){let t=e.toLowerCase();return Object.keys(H).map(n=>{let r=n.toLowerCase();return{name:n,distance:Jn(t,r),prefix:Wn(t,r)}}).filter(({name:n,distance:r,prefix:o})=>r<=Math.max(2,n.length/3)||o>=4).sort((n,r)=>r.prefix-n.prefix||n.distance-r.distance).slice(0,3).map(({name:n})=>n)}function Wn(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return n}function Jn(e,t){let n=Array.from({length:t.length+1},(r,o)=>o);for(let r=1;r<=e.length;r++){let o=[r];for(let s=1;s<=t.length;s++)o[s]=Math.min((n[s]??0)+1,(o[s-1]??0)+1,(n[s-1]??0)+(e[r-1]===t[s-1]?0:1));n=o}return n[t.length]??0}var zn=`gs configure \u2014 view and edit a store's configuration.
36
+ `),0}import*as at from"fs";import*as ct from"os";import*as te from"path";import{existsSync as Vn}from"fs";import*as be from"path";import{fileURLToPath as Jn}from"url";var ue="greatstore";function st(){for(let e of["./gs-skill/","../../gs-skill/"]){let t=be.resolve(Jn(new URL(e,import.meta.url)));if(Vn(be.join(t,"SKILL.md")))return t}throw new Error("internal: this install of the CLI is missing the agent skill files")}function lt(){process.stdout.write(Kn(st()))}function Kn(e){if(Wn(e))throw new Error(["This copy of the CLI is running from a temporary cache, so the agent","skill has no stable location to install from. Install the CLI first,","then ask again:",""," npm install -g @greatstore/cli"," gs skill"].join(`
37
+ `));return["GreatStore agent skill \u2014 installation instructions for an AI coding agent.","","Skill source on this machine:",` ${e}`,"",`Symlink that folder into your skills directory as "${ue}":`,""," mkdir -p <SKILLS_DIR>",` ln -sfn "${e}" "<SKILLS_DIR>/${ue}"`,"","Symlink it, do not copy it: the link keeps the skill current every","time @greatstore/cli is upgraded, with nothing to re-run.","","<SKILLS_DIR> is wherever you load skills from \u2014 for Claude Code that","is ~/.claude/skills for every project, or ./.claude/skills for this","one. Use your own location if it differs, and create it if missing.",`Then read <SKILLS_DIR>/${ue}/SKILL.md to confirm the install.`,"",`On Windows: mklink /D "<SKILLS_DIR>\\${ue}" "${e}"`,""].join(`
38
+ `)}function Wn(e){let t=e.split(te.sep).join("/");if(/\/(?:_npx|_cacache|\.bun\/install\/cache)\//.test(t)||/\/(?:dlx-|bunx-|\.npx-)/.test(t))return!0;let n=ct.tmpdir();return it(e,n)||it(e,zn(n))}function it(e,t){let n=te.relative(t,e);return n!==""&&!n.startsWith("..")&&!te.isAbsolute(n)}function zn(e){try{return at.realpathSync(e)}catch{return e}}var M={mode:{kind:"string",values:["auto","light","dark","custom"],help:"Color scheme. `auto` follows the shopper's system preference.",brandVisible:!0},radius:{kind:"string",values:["sharp","default","rounded"],help:"Corner rounding preset applied to every surface.",brandVisible:!0},panelPosition:{kind:"string",values:["left","right","middle"],help:"Where the chat panel sits on desktop.",brandVisible:!0},fontFamily:{kind:"string",help:"Primary font family name.",brandVisible:!0},secondaryFontFamily:{kind:"string",help:"Font family for the assistant's chat bubbles.",brandVisible:!0},mobileBottomBar:{kind:"boolean",help:"Show the compact bottom bar on mobile.",brandVisible:!0},zIndex:{kind:"integer",help:"Stacking order of the chat panel on the host page."},brandColor:{kind:"color",help:"Accent color.",brandVisible:!0},surfaceColor:{kind:"color",help:"Background color.",brandVisible:!0},textColor:{kind:"color",help:"Text color.",brandVisible:!0},surface:{kind:"color",help:"Panel background."},surfaceSecondary:{kind:"color",help:"Secondary background."},surfaceAccent:{kind:"color",help:"Accented background."},surfaceHover:{kind:"color",help:"Hovered background."},foreground:{kind:"color",help:"Body text."},foregroundSecondary:{kind:"color",help:"Secondary text."},foregroundMuted:{kind:"color",help:"Muted text."},foregroundAccent:{kind:"color",help:"Accented text."},border:{kind:"color",help:"Border color."},borderFocus:{kind:"color",help:"Focus-ring color."},primary:{kind:"color",help:"Primary button background."},primaryForeground:{kind:"color",help:"Primary button text."},primaryHover:{kind:"color",help:"Primary button hover."},primaryMuted:{kind:"color",help:"Muted primary background."},primaryMutedForeground:{kind:"color",help:"Muted primary text."},primaryTint:{kind:"color",help:"Primary tint wash."},link:{kind:"color",help:"Link color."}};function ut(e){let t=e.toLowerCase();return Object.keys(M).map(n=>{let r=n.toLowerCase();return{name:n,distance:Yn(t,r),prefix:Xn(t,r)}}).filter(({name:n,distance:r,prefix:o})=>r<=Math.max(2,n.length/3)||o>=4).sort((n,r)=>r.prefix-n.prefix||n.distance-r.distance).slice(0,3).map(({name:n})=>n)}function Xn(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return n}function Yn(e,t){let n=Array.from({length:t.length+1},(r,o)=>o);for(let r=1;r<=e.length;r++){let o=[r];for(let s=1;s<=t.length;s++)o[s]=Math.min((n[s]??0)+1,(o[s-1]??0)+1,(n[s-1]??0)+(e[r-1]===t[s-1]?0:1));n=o}return n[t.length]??0}var Qn=`gs configure \u2014 view and edit a store's configuration.
39
39
 
40
40
  Usage:
41
41
  gs configure Show the current configuration.
@@ -48,8 +48,8 @@ Run \`gs configure set --help\` for the full field list.
48
48
  Flags:
49
49
  --store <slug> Which store to act on (default: nearest .gsrc).
50
50
  --json Machine-readable output.
51
- `;function Xn(){let e=Object.entries(H).map(([n,r])=>{let o=r.values?r.values.join(" | "):r.kind==="color"?"<css color>":r.kind==="boolean"?"true | false":r.kind==="integer"?"<integer>":"<name>";return{flag:` --theme.${n} ${o}`,help:r.help}}),t=Math.max(...e.map(n=>n.flag.length))+2;return e.map(n=>`${n.flag.padEnd(t)}${n.help}`).join(`
52
- `)}function Yn(){return Object.entries(H).filter(([,e])=>e.brandVisible).map(([e])=>e).join(", ")}function Qn(){return`gs configure set \u2014 save configuration fields.
51
+ `;function Zn(){let e=Object.entries(M).map(([n,r])=>{let o=r.values?r.values.join(" | "):r.kind==="color"?"<css color>":r.kind==="boolean"?"true | false":r.kind==="integer"?"<integer>":"<name>";return{flag:` --theme.${n} ${o}`,help:r.help}}),t=Math.max(...e.map(n=>n.flag.length))+2;return e.map(n=>`${n.flag.padEnd(t)}${n.help}`).join(`
52
+ `)}function er(){return Object.entries(M).filter(([,e])=>e.brandVisible).map(([e])=>e).join(", ")}function tr(){return`gs configure set \u2014 save configuration fields.
53
53
 
54
54
  Only the fields you pass are written; everything else is left alone. Pass an
55
55
  empty value to clear a field (e.g. --displayName "").
@@ -63,7 +63,7 @@ Store fields:
63
63
  --cspConnectHosts <a,b,c> Extra connect hosts to allow.
64
64
 
65
65
  Theme fields (merge into the stored theme):
66
- ${Xn()}
66
+ ${Zn()}
67
67
 
68
68
  Whole-object theme writes:
69
69
  --theme '<json>' Merge this JSON object into the stored theme.
@@ -72,51 +72,54 @@ Whole-object theme writes:
72
72
  --theme "" Clear the theme entirely.
73
73
 
74
74
  These are shopper-visible, so confirm them with the merchant before writing:
75
- ${Yn()}
75
+ ${er()}
76
76
 
77
77
  Examples:
78
78
  gs configure set --theme.fontFamily Manrope --theme.radius sharp
79
79
  gs configure set --theme.brandColor "#1e1d66"
80
80
  gs configure set --theme '{"mode":"dark"}' --replace
81
- `}function lt(e){if(e===void 0||e==="show")return zn;if(e==="set")return Qn()}import*as g from"fs";import*as x from"path";import{readdirSync as So,readFileSync as vo}from"fs";import{fileURLToPath as ko}from"url";var be=null;function pt(){return be||(be=JSON.parse('{"component/component.tsx":"import React from \\"react\\";\\n\\n// Add your tool args (matching manifest.json#inputSchema.properties)\\n// alongside the GreatStore-injected lifecycle props. See AGENTS.md for\\n// what each lifecycle prop does.\\ninterface Props {\\n onSendMessage: (text: string) => void;\\n onCallTool: (name: string, args: Record<string, unknown>) => void;\\n onUpdateModelContext: (context: string) => void;\\n onShowLightbox: (options: { src: string; originRect?: DOMRect }) => void;\\n onClose: () => void;\\n // Ask the store\'s assistant for content matching a JSON Schema (or Zod\\n // schema). Resolves to the generated object. `fallback` is a required,\\n // schema-shaped stand-in rendered in the component preview (and validated\\n // against the schema). See AGENTS.md.\\n onGenerateStructuredContent: <T = unknown>(\\n schema: object,\\n prompt: string,\\n fallback: T,\\n ) => Promise<T>;\\n // Drop-in for <img>: `<Image src=\u2026 alt=\u2026 />`. See AGENTS.md.\\n Image: React.ElementType<React.ComponentProps<\\"img\\">>;\\n}\\n\\n// See AGENTS.md for the design rules (em-based sizing, brand CSS\\n// variables), the lifecycle props, and how to write an async,\\n// backend-backed component.\\nexport default function __GS_PASCAL__(_props: Props): React.ReactElement {\\n return (\\n <div\\n style={{\\n padding: \\"1em\\",\\n border: \\"1px solid var(--color-border-default)\\",\\n borderRadius: \\"var(--radius-lg)\\",\\n background: \\"var(--color-surface)\\",\\n color: \\"var(--color-foreground)\\",\\n fontFamily: \\"var(--font-primary)\\",\\n }}\\n >\\n <strong>__GS_NAME__</strong> \u2014 hello from your component!\\n </div>\\n );\\n}\\n","component/manifest.json":"{\\n \\"name\\": \\"__GS_NAME__\\",\\n \\"displayName\\": \\"__GS_DISPLAY_NAME__\\",\\n \\"description\\": \\"Renders the __GS_NAME__ widget.\\",\\n \\"displayMode\\": \\"inline\\",\\n \\"inputSchema\\": {\\n \\"type\\": \\"object\\",\\n \\"properties\\": {}\\n }\\n}\\n","root/.gitignore":"node_modules/\\ncomponents/*/bundle.js\\ncomponents/*/.gssync.json\\n*.tsbuildinfo\\n.DS_Store\\n","root/.gsrc":"{\\n \\"store\\": \\"__GS_STORE__\\"\\n}\\n","root/AGENTS.md":"# AGENTS.md\\n\\n> **Do not edit \u2014 auto-generated by the GreatStore CLI v__GS_VERSION__.**\\n> This file is rewritten by `gs apps init`, so any changes you make here\\n> will be overwritten. If this version trails your installed CLI, re-run\\n> `gs apps init` to refresh it. Put project-specific notes in another file.\\n\\nGuidance for AI coding agents working on the components in this project.\\n`CLAUDE.md` and `GEMINI.md` are symlinks to this file.\\n\\nThese components render inside arbitrary publisher websites (the embed\\nwidget mounts on a host page) as well as the GreatStore storefront. You\\ncontrol neither the host page\'s base font size nor its color scheme, and\\nthe store owner controls the look from GreatStore theme settings. The\\nrules below keep components portable across both.\\n\\n## Design requirements\\n\\n### Never use `rem` for fonts and sizing \u2014 always use `em`\\n\\n`rem` resolves against the host page\'s root font size, which is\\narbitrary and outside our control. A host that sets `html { font-size:\\n8px }` (or 200%) will shrink or blow up every `rem`-based dimension.\\n`em` resolves against the component\'s own font size, so it stays\\nself-consistent wherever the component is mounted.\\n\\nUse `em` for font sizes, padding, margins, gaps, widths, heights,\\nand any other length. Borders may stay in `px` (hairlines should not\\nscale with text).\\n\\n```tsx\\n// Bad \u2014 breaks on hosts with a non-default root font size\\n<div style={{ padding: \\"1rem\\", fontSize: \\"0.875rem\\" }} />\\n\\n// Good\\n<div style={{ padding: \\"1em\\", fontSize: \\"0.875em\\" }} />\\n```\\n\\n### Don\'t hardcode colors, fonts, or corner radius \u2014 use GreatStore brand variables\\n\\nThe store owner themes the assistant from GreatStore settings. Hardcoded\\nvalues ignore that and make the component clash with the rest of the\\nstore. Read from the CSS variables GreatStore injects on the surface\\ninstead, so the component restyles itself when the theme changes.\\n\\nAvailable variables:\\n\\n| Purpose | Variable |\\n| --- | --- |\\n| Surface background | `--color-surface` |\\n| Secondary surface | `--color-surface-secondary` |\\n| Accent surface | `--color-surface-accent` |\\n| Hover surface | `--color-surface-hover` |\\n| Foreground text | `--color-foreground` |\\n| Secondary text | `--color-foreground-secondary` |\\n| Muted text | `--color-foreground-muted` |\\n| Accent text | `--color-foreground-accent` |\\n| Border | `--color-border-default` |\\n| Focus border | `--color-border-focus` |\\n| Primary / brand | `--color-primary` |\\n| Text on primary | `--color-primary-foreground` |\\n| Primary hover | `--color-primary-hover` |\\n| Primary muted | `--color-primary-muted` |\\n| Text on primary muted | `--color-primary-muted-foreground` |\\n| Primary tint | `--color-primary-tint` |\\n| Link | `--color-link` |\\n| Font family | `--font-primary` |\\n| Secondary font family | `--font-secondary` |\\n| Corner radius (scale) | `--radius-xs` \u2026 `--radius-4xl`, `--radius-pill` |\\n\\nThe store owner can set a secondary font family in their GreatStore\\ntheme settings, exposed as `--font-secondary` (it falls back to\\n`--font-primary` when unset). Reach for it to add a tasteful second\\nlayer of typography \u2014 pair `--font-primary` for body copy with\\n`--font-secondary` for headings, prices, or other accents \u2014 so the\\ncomponent reflects the store\'s full type system instead of a single\\nface.\\n\\n```tsx\\n// Bad \u2014 hardcoded, ignores the store\'s theme\\n<button style={{ background: \\"#4f46e5\\", borderRadius: 8, fontFamily: \\"Inter\\" }} />\\n\\n// Good\\n<button\\n style={{\\n background: \\"var(--color-primary)\\",\\n color: \\"var(--color-primary-foreground)\\",\\n borderRadius: \\"var(--radius-lg)\\",\\n fontFamily: \\"var(--font-primary)\\",\\n }}\\n/>\\n```\\n\\nProvide a sensible fallback only when a value might be absent, e.g.\\n`var(--color-primary, currentColor)`.\\n\\n## Component props\\n\\nEach component receives its tool args (the fields you declare in\\n`manifest.json#inputSchema.properties`) plus these GreatStore-injected\\nlifecycle props, which are always present:\\n\\n| Prop | What it does |\\n| --- | --- |\\n| `onSendMessage(text)` | Send text into the chat as if the shopper typed it. |\\n| `onCallTool(name, args)` | Chain into another remote-component tool by name. |\\n| `onUpdateModelContext(context)` | Inject invisible background context for the model (selected variant, configured options, current step). Replaces the prior value \u2014 never appends; pass `\\"\\"` to clear. Read on the next chat turn. Use it when the assistant should *know* in-component state without a visible message; use `onSendMessage` when you want a turn to happen now. |\\n| `onShowLightbox({ src, originRect? })` | Expand an image in the chat\'s shared full-screen lightbox \u2014 an on-brand zoom overlay your component can\'t render itself (it\'s boxed inside its own bounds and shadow root). Pass the image `src`; for a smooth zoom, also pass the clicked element\'s `getBoundingClientRect()` as `originRect` (omit it and the image grows from the viewport centre). |\\n| `onGenerateStructuredContent(schema, prompt, fallback)` | Ask the store\'s assistant for content matching a JSON Schema (or a Zod schema); resolves to the generated object. Personalized to the shopper. Works the same in the conversation on the storefront and every embed. Best inside an async component that builds its render from the generated payload \u2014 `await` it, then return the JSX. `fallback` is **required**: a schema-shaped object you supply that the component preview renders (so a generation-driven component previews without a live store). It\'s validated against the schema and throws if the two don\'t line up. |\\n| `onClose()` | Dismiss the host slot. Over-input clears the overlay, fullscreen reverts the pane, inline is a no-op. |\\n| `Image` | A drop-in for `<img>`: render `<Image src=\u2026 alt=\u2026 />` instead of `<img>` and your images are automatically served at the right size for the store. Takes the same props as `<img>` (`src`, `alt`, `style`, `loading`, `onClick`, \u2026). Previewing the component outside the store? Pass `Image={\\"img\\"}` (or your own component) to render a plain image. |\\n\\n## Async components (backend-backed, render-blocking data)\\n\\nIf a component must load data from a backend/API before it can render\\ncorrectly, make it async \u2014 don\'t render an empty shell and fetch in a\\n`useEffect`. Set `\\"async\\": true` in `manifest.json` and export an async\\ndefault. GreatStore waits for your promise (showing a normal loading\\nstate, so you don\'t render your own placeholder), then renders what it\\nresolves to. Components that render purely from their props stay\\nsynchronous.\\n\\nA thrown error is a **retry signal**: the in-store AI sees it and\\nusually re-calls the tool. So only throw when a *different* call could\\nhelp:\\n\\n1. `await` the backend call, then return the finished JSX.\\n2. Validate the AI-passed props first and throw on bad input \u2014 the AI\\n can fix the args and retry. (Don\'t validate the API\'s *output* and\\n throw: the AI can\'t fix the backend, it\'ll just loop.)\\n3. Broadcast a backend failure ONLY when retrying differently could\\n succeed, and say what to change (e.g. empty search \u2192 \\"try a broader\\n keyword\\"). For idempotent failures (500, timeout, missing record)\\n re-running the same call changes nothing \u2014 render a graceful fallback\\n instead of throwing.\\n\\n```tsx\\nexport default async function Example(props: Props) {\\n if (!props.query?.trim()) throw new Error(\\"missing required prop: query\\");\\n const res = await fetch(`/api/search?q=${encodeURIComponent(props.query)}`);\\n if (res.ok) {\\n const { results } = await res.json();\\n if (results.length === 0)\\n throw new Error(`no results for \\"${props.query}\\" \u2014 try a broader keyword`);\\n return <ul>{/* render results */}</ul>;\\n }\\n return <p>Couldn\'t load results right now.</p>; // idempotent: don\'t throw\\n}\\n```\\n","root/README.md":"# GreatStore components\\n\\nCustom React components published to your GreatStore tenant. Each\\ncomponent lives in its own folder under `components/`.\\n\\n```\\nnpm install\\ngs apps init <component_name> # add a new component\\ngs apps build # builds every components/<name>/bundle.js\\ngs apps push # uploads every changed component as a draft\\ngs apps publish <component_name> # promote a specific component to live\\n```\\n\\n- `gs apps push` (no args) hashes each component and only uploads the ones\\n that have changed since the last sync.\\n- `gs apps pull` (no args) refreshes every remote component into\\n `components/<name>/`. Components with unsaved local edits are skipped\\n with a warning; pass `--force` to overwrite.\\n\\nSee `AGENTS.md` for the design rules every component must follow\\n(em-based sizing, brand CSS variables) \u2014 it doubles as guidance for AI\\ncoding agents (`CLAUDE.md` / `GEMINI.md` symlink to it).\\n","root/package.json":"{\\n \\"name\\": \\"greatstore-components\\",\\n \\"version\\": \\"0.0.1\\",\\n \\"private\\": true,\\n \\"type\\": \\"module\\",\\n \\"scripts\\": {\\n \\"build\\": \\"gs apps build\\",\\n \\"push\\": \\"gs apps build && gs apps push\\"\\n },\\n \\"dependencies\\": {\\n \\"react\\": \\"^19.0.0\\",\\n \\"react-dom\\": \\"^19.0.0\\"\\n },\\n \\"devDependencies\\": {\\n \\"@types/react\\": \\"^19.0.0\\",\\n \\"@types/react-dom\\": \\"^19.0.0\\",\\n \\"@vitejs/plugin-react\\": \\"^4.3.0\\",\\n \\"typescript\\": \\"^5.6.0\\",\\n \\"vite\\": \\"^5.4.0\\"\\n }\\n}\\n","root/tsconfig.json":"{\\n \\"compilerOptions\\": {\\n \\"target\\": \\"ES2022\\",\\n \\"module\\": \\"ESNext\\",\\n \\"moduleResolution\\": \\"Bundler\\",\\n \\"jsx\\": \\"react-jsx\\",\\n \\"lib\\": [\\"ES2022\\", \\"DOM\\"],\\n \\"strict\\": true,\\n \\"esModuleInterop\\": true,\\n \\"skipLibCheck\\": true,\\n \\"isolatedModules\\": true,\\n \\"noEmit\\": true\\n },\\n \\"include\\": [\\"components/**/component.tsx\\", \\"vite.config.ts\\"]\\n}\\n","root/vite.config.ts":"import { defineConfig } from \\"vite\\";\\nimport react from \\"@vitejs/plugin-react\\";\\n\\n// Real builds happen in `gs build` (one Vite invocation per\\n// component, externals + runtime shim paths owned by the CLI). This\\n// file exists only so editors / language servers can resolve the\\n// React plugin when inspecting components/*/component.tsx.\\nexport default defineConfig({\\n plugins: [react()],\\n});\\n"}'),be)}var ut={name:"__GS_NAME__",pascalName:"__GS_PASCAL__",displayName:"__GS_DISPLAY_NAME__",store:"__GS_STORE__",version:"__GS_VERSION__"};function ft(e,t){let n=e;for(let o of Object.keys(ut)){let s=t[o];s!==void 0&&(n=n.split(ut[o]).join(s))}let r=n.match(/__GS_[A-Z_]+__/);if(r)throw new Error(`internal: template placeholder ${r[0]} was not provided`);return n}var dt=/^[a-z][a-z0-9_]*$/;function gt(e){let t=e.positional[0];if(t!==void 0&&!dt.test(t))throw new Error(`Invalid component name: "${t}" (must match ${dt}).`);let n=m(e.flags,"force"),r=h(e.flags,"store"),o=h(e.flags,"out")??".",s=x.resolve(o),i=Zn(s),a;if(i){if(r!==void 0)throw new Error(`Project at ${s} is already pinned to a store via .gsrc. Drop --store; a project folder ships to exactly one store.`);E({cwd:s})}else if(a=r!==void 0?Y(r):oe()??void 0,a===void 0){let u=t?`gs apps init ${t} --store <slug>`:"gs apps init --store <slug>";throw new Error(`--store <slug> is required when scaffolding a new project root. Run \`${u}\`.`)}let l=er(s,i,n,{store:a});if(!t){let u=[];i?(u.push(`Updated GreatStore project root in ${s}.`),l.length>0?u.push("",`Added: ${l.join(", ")}`):u.push("","Already up to date \u2014 nothing to add.")):u.push(`Scaffolded GreatStore project root in ${s}.`),u.push("","Next steps:",` cd ${x.relative(process.cwd(),s)||"."}`," npm install"," gs apps init <component_name> # add your first component",""),process.stdout.write(u.join(`
82
- `));return}let c=x.join(s,"components",t);rr(c,t,n);let p=x.relative(process.cwd(),s)||".";process.stdout.write([`Added component "${t}" at components/${t}/.`,...i&&l.length>0?["",`Also added to the project root: ${l.join(", ")}`]:[],"","Next steps:",...i?[]:[` cd ${p}`," npm install"],` # edit components/${t}/component.tsx and manifest.json`," gs apps build"," gs apps push",""].join(`
83
- `))}function Zn(e){return g.existsSync(x.join(e,"package.json"))&&g.existsSync(x.join(e,".gsrc"))}function er(e,t,n,r){if(g.mkdirSync(e,{recursive:!0}),!t&&!n&&g.readdirSync(e).filter(a=>a!==".gsrc").length>0)throw new Error(`Refusing to scaffold project root into non-empty directory ${e}. Pass --force to override.`);let o=t?sr():or({store:r.store}),s=nr(e,o,n);return g.mkdirSync(x.join(e,"components"),{recursive:!0}),s}var tr=new Set(["AGENTS.md"]);function nr(e,t,n){let r=[];for(let[o,s]of t){let i=x.join(e,o);g.mkdirSync(x.dirname(i),{recursive:!0});let a=g.existsSync(i);if(!n&&a&&!tr.has(o))continue;let l=!a||g.readFileSync(i,"utf8")!==s;g.writeFileSync(i,s),l&&r.push(o)}for(let o of["CLAUDE.md","GEMINI.md"]){let s=x.join(e,o);n&&mt(s)&&g.rmSync(s),mt(s)||(g.symlinkSync("AGENTS.md",s),r.push(o))}return r}function mt(e){try{return g.lstatSync(e),!0}catch{return!1}}function rr(e,t,n){if(g.existsSync(e)&&!n&&g.readdirSync(e).length>0)throw new Error(`Refusing to overwrite existing components/${t}/. Pass --force to override.`);g.mkdirSync(e,{recursive:!0});for(let[r,o]of ir(t))g.writeFileSync(x.join(e,r),o)}function Te(e,t,n=new Set){let r=pt();return Object.entries(r).filter(([o])=>o.startsWith(e)).map(([o,s])=>[o.slice(e.length),s]).filter(([o])=>!n.has(o)).map(([o,s])=>[o,ft(s,t)])}function or(e){if(!e.store)throw new Error("internal: rootFiles called without a store slug");return Te("root/",{store:e.store,version:F})}function sr(){return Te("root/",{version:F},new Set([".gsrc"]))}function ir(e){return Te("component/",{name:e,pascalName:cr(e),displayName:ar(e)})}function ar(e){let t=e.split("_").filter(Boolean);if(t.length===0)return e;let n=t[0];return n.charAt(0).toUpperCase()+n.slice(1)+(t.length>1?" "+t.slice(1).join(" "):"")}function cr(e){return e.split(/[_-]/).filter(Boolean).map(t=>t[0]?.toUpperCase()+t.slice(1)).join("")}import*as S from"fs";import*as w from"path";import{createRequire as Sr}from"module";import*as Et from"fs";import*as M from"path";import{createRequire as lr}from"module";import*as Se from"path";function yt(e,t,n){let r=bt(e);if(!r)return{ok:!1,reason:"couldn't check props against the manifest \u2014 `typescript` isn't installed in this project (run `npm install`)"};try{let o=r.createSourceFile(t,n,r.ScriptTarget.Latest,!0,r.ScriptKind.TSX),s=pr(r,o);return s?mr(r,o,s):{ok:!1,reason:"couldn't find a default-exported component function to check props against \u2014 export the component as `export default function \u2026`"}}catch(o){return{ok:!1,reason:`couldn't check props against the manifest \u2014 ${Se.basename(t)} could not be parsed (${o.message})`}}}function wt(e,t,n){let r=bt(e);if(!r)return!1;try{let o=r.createSourceFile(t,n,r.ScriptTarget.Latest,!0,r.ScriptKind.TSX),s=!1,i=a=>{if(!s){if(ur(r,a)){s=!0;return}r.forEachChild(a,i)}};return i(o),s}catch{return!1}}function ur(e,t){if(e.isPropertyAccessExpression(t))return ht(e,t.expression)&&t.name.text==="GreatStore";if(e.isElementAccessExpression(t)){let n=t.argumentExpression;return ht(e,t.expression)&&e.isStringLiteralLike(n)&&n.text==="GreatStore"}return!1}function ht(e,t){return e.isIdentifier(t)&&(t.text==="window"||t.text==="globalThis")}function bt(e){let t=lr(Se.join(e,"package.json"));try{return t("typescript")}catch{return null}}function pr(e,t){let n=null;for(let o of t.statements){if(e.isFunctionDeclaration(o)&&fr(e,o))return o;e.isExportAssignment(o)&&!o.isExportEquals&&(n=o.expression)}if(!n)return null;let r=St(e,n);return e.isArrowFunction(r)||e.isFunctionExpression(r)?r:e.isIdentifier(r)?dr(e,t,r.text):null}function fr(e,t){return t.modifiers?.some(n=>n.kind===e.SyntaxKind.DefaultKeyword)??!1}function St(e,t){let n=t;for(;e.isParenthesizedExpression(n)||e.isAsExpression(n)||e.isSatisfiesExpression(n);)n=n.expression;return n}function dr(e,t,n){for(let r of t.statements){if(e.isFunctionDeclaration(r)&&r.name?.text===n)return r;if(e.isVariableStatement(r))for(let o of r.declarationList.declarations){if(!e.isIdentifier(o.name)||o.name.text!==n||!o.initializer)continue;let s=St(e,o.initializer);if(e.isArrowFunction(s)||e.isFunctionExpression(s))return s}}return null}function mr(e,t,n){let r=n.parameters[0];if(!r)return{ok:!0,props:{names:[],open:!1}};if(r.type){let o=Le(e,t,r.type,new Set);if(o)return{ok:!0,props:o}}return e.isObjectBindingPattern(r.name)?{ok:!0,props:gr(e,r.name)}:{ok:!1,reason:"couldn't check props against the manifest \u2014 declare the component's props as a local `interface`/`type` or destructure them in the signature"}}function Le(e,t,n,r){if(e.isTypeLiteralNode(n))return xt(e,n.members);if(e.isTypeReferenceNode(n)&&e.isIdentifier(n.typeName))return vt(e,t,n.typeName.text,r);if(e.isIntersectionTypeNode(n)){let o=n.types.map(s=>Le(e,t,s,r));return o.every(s=>s===null)?null:Pt(o.map(s=>s??{names:[],open:!0}))}return null}function vt(e,t,n,r){if(r.has(n))return{names:[],open:!1};r.add(n);for(let o of t.statements){if(e.isInterfaceDeclaration(o)&&o.name.text===n){let s=xt(e,o.members),i=(o.heritageClauses??[]).flatMap(a=>a.types.map(l=>e.isIdentifier(l.expression)?vt(e,t,l.expression.text,r)??{names:[],open:!0}:{names:[],open:!0}));return Pt([s,...i])}if(e.isTypeAliasDeclaration(o)&&o.name.text===n)return Le(e,t,o.type,r)}return null}function xt(e,t){let n=[],r=!1;for(let o of t){if(e.isIndexSignatureDeclaration(o)){r=!0;continue}if(!e.isPropertySignature(o)&&!e.isMethodSignature(o))continue;let s=kt(e,o.name);if(s===null){r=!0;continue}n.push(s)}return{names:n,open:r}}function gr(e,t){let n=[],r=!1;for(let o of t.elements){if(o.dotDotDotToken){r=!0;continue}let s=o.propertyName??o.name,i=kt(e,s);i===null?r=!0:n.push(i)}return{names:n,open:r}}function kt(e,t){return e.isIdentifier(t)||e.isStringLiteral(t)?t.text:null}function Pt(e){let t=[],n=!1;for(let r of e){for(let o of r.names)t.includes(o)||t.push(o);n||=r.open}return{names:t,open:n}}function At(e){let{root:t,name:n}=e,r=M.join(t,"components",n),o=e.manifestPath??M.join(r,"manifest.json"),s=e.sourcePath??M.join(r,"component.tsx"),i=$t(t,o),a=$t(t,s),l=[],c=null,p=Ct(o);if(p===null)l.push({severity:"error",rule:"manifest/missing",file:i,message:"manifest not found."});else try{let k=JSON.parse(p);!k||typeof k!="object"||Array.isArray(k)?l.push({severity:"error",rule:"manifest/invalid",file:i,message:"manifest must be a JSON object."}):c=k}catch(k){l.push({severity:"error",rule:"manifest/invalid",file:i,message:`manifest is not valid JSON: ${k.message}`})}let u=Ct(s),f=u===null?{ok:!1,reason:`couldn't check props against the manifest \u2014 ${a} not found`}:yt(t,s,u),j=u===null?!1:wt(t,s,u);return{ctx:{name:n,manifestFile:i,sourceFile:a,manifest:c,props:f,usesWindowGreatStore:j},diagnostics:l}}function Ct(e){try{return Et.readFileSync(e,"utf8")}catch{return null}}function $t(e,t){let n=M.relative(e,t);return n.startsWith("..")?t:n.split(M.sep).join("/")}var jt=new Set(["onSendMessage","onCallTool","onClose","onUpdateModelContext","onShowLightbox","onGenerateStructuredContent","storeData","Image"]);var Rt=new Map([["onError",'prop `onError` is deprecated and no longer provided \u2014 prefer an async component to report failures. Drop the prop; see the "Async components" section in AGENTS.md for how to signal errors.']]);function Tt(e){if(!e.manifest)return[];let t=yr(e.manifest.inputSchema);if(t===null)return[];if(!e.props.ok)return[{severity:"warning",rule:"props/not-analyzable",file:e.sourceFile,message:`${e.props.reason}.`}];if(e.props.props.open)return[];let n=new Set(e.props.props.names),r=new Set(t),o=[];for(let i of e.props.props.names){if(jt.has(i))continue;let a=Rt.get(i);if(a){o.push({severity:"warning",rule:"props/retired-lifecycle",file:e.sourceFile,message:a});continue}r.has(i)||o.push({severity:"warning",rule:"props/undeclared",file:e.sourceFile,message:`prop \`${i}\` is not declared in ${e.manifestFile}#inputSchema.properties, so nothing will ever pass it. Declare it in the schema, or drop it from the component.`})}let s=t.filter(i=>!n.has(i));return s.length>0&&o.push({severity:"error",rule:"props/missing",file:e.sourceFile,message:hr(e.manifestFile,s)}),o}var _t=8;function hr(e,t){if(t.length===1){let[s]=t;return`${e} declares inputSchema field \`${s}\`, but the component does not accept a \`${s}\` prop. Add it to the component's props, or remove it from the schema.`}let n=t.slice(0,_t).map(s=>`\`${s}\``).join(", "),r=t.length-_t,o=r>0?`${n} (+${r} more)`:n;return`${e} declares ${t.length} inputSchema fields the component does not accept: ${o}. Add them to the component's props, or remove them from the schema.`}function yr(e){if(!e||typeof e!="object")return null;let t=e.properties;return!t||typeof t!="object"||Array.isArray(t)?null:Object.keys(t)}var wr=["anyOf","oneOf","allOf","$ref","not"];function ve(e,t,n){if(Array.isArray(e)){e.forEach((s,i)=>ve(s,`${t}[${i}]`,n));return}if(!e||typeof e!="object")return;let r=e;for(let s of wr)s in r&&n.unionPaths.push(`${t}.${s}`);let o=r.properties;if(o&&typeof o=="object"&&!Array.isArray(o))for(let[s,i]of Object.entries(o))n.fields+=1,ve(i,`${t}.${s}`,n);"items"in r&&ve(r.items,`${t}[]`,n)}function Lt(e){let t=e.manifest?.inputSchema;if(!t||typeof t!="object")return[];let n={bytes:Buffer.byteLength(JSON.stringify(t),"utf8"),fields:0,unionPaths:[]};ve(t,"inputSchema",n);let r=[];if(n.unionPaths.length>0){let o=n.unionPaths.slice(0,3).join(", "),s=n.unionPaths.length>3?` (+${n.unionPaths.length-3} more)`:"";r.push(`uses ${o}${s} \u2014 declare exactly one type per field; accept alternate shapes in component code instead`)}return n.bytes>8192&&r.push(`is ${(n.bytes/1024).toFixed(1)} KB serialized (limit ${8192/1024} KB)`),n.fields>50&&r.push(`declares ${n.fields} fields (limit 50)`),r.length===0?[]:[{severity:"error",rule:"manifest/input-schema-too-complex",file:e.manifestFile,message:`inputSchema ${r.join("; ")}.
84
- A schema this complex is usually a sign the component is overengineered, and the assistant will fill it unreliably or stop calling the tool altogether. Keep it to a small set of flat, single-type fields (one canonical name per concept \u2014 no aliases), and let component code handle formatting, fallbacks, and edge cases.`}]}function Ot(e){let t=e.manifest?.name;return typeof t!="string"||t===e.name?[]:[{severity:"error",rule:"manifest/name-mismatch",file:e.manifestFile,message:`manifest name "${t}" does not match folder name "${e.name}".`}]}function It(e){return e.usesWindowGreatStore?[{severity:"warning",rule:"globals/window-greatstore",file:e.sourceFile,message:"this component reads `window.GreatStore`, the host-page embed API. Components should interact with GreatStore through their injected lifecycle props (`onSendMessage`, `onCallTool`, `onGenerateStructuredContent`, \u2026) instead \u2014 those are wired to the surface the component is mounted in."}]:[]}function ae(e){return e.filter(t=>t.severity==="error")}function Oe(e){return e.filter(t=>t.severity==="warning")}function ce(e){return`${e.severity==="error"?"error":"warning"} ${e.file}: ${e.message}`}var br=[Ot,Lt,Tt,It];function xe(e){let{ctx:t,diagnostics:n}=At(e);for(let r of br)n.push(...r(t));return{diagnostics:n,ok:ae(n).length===0}}var K="components";async function Nt(e){let t=process.cwd();if(!S.existsSync(w.join(t,"package.json"))||!S.existsSync(w.join(t,K)))throw new Error(`\`gs apps build\` must run from a project root (contains \`package.json\` and \`${K}/\`). Current dir: ${t}`);let n=vr(t);if(n.length===0){process.stdout.write(`(no components in ./${K} \u2014 run \`gs apps init <name>\` to add one)
85
- `);return}let r=e.positional[0],o=r?n.filter(p=>p===r):n;if(r&&o.length===0)throw new Error(`No component named "${r}" in ./${K}`);let s=[],i=[];for(let p of o){let u=xe({root:t,name:p});for(let f of u.diagnostics)process.stdout.write(` ${ce(f)}
81
+ `}function pt(e){if(e===void 0||e==="show")return Qn;if(e==="set")return tr()}import*as g from"fs";import*as k from"path";import{readdirSync as $o,readFileSync as Co}from"fs";import{fileURLToPath as Ao}from"url";var ve=null;function dt(){return ve||(ve=JSON.parse('{"component/component.tsx":"import React from \\"react\\";\\n\\n// Add your tool args (matching manifest.json#inputSchema.properties)\\n// alongside the GreatStore-injected lifecycle props. See AGENTS.md for\\n// what each lifecycle prop does.\\ninterface Props {\\n onSendMessage: (text: string) => void;\\n onCallTool: (name: string, args: Record<string, unknown>) => void;\\n onUpdateModelContext: (context: string) => void;\\n onShowLightbox: (options: { src: string; originRect?: DOMRect }) => void;\\n onClose: () => void;\\n // Ask the store\'s assistant for content matching a JSON Schema (or Zod\\n // schema). Resolves to the generated object. `fallback` is a required,\\n // schema-shaped stand-in rendered in the component preview (and validated\\n // against the schema). See AGENTS.md.\\n onGenerateStructuredContent: <T = unknown>(\\n schema: object,\\n prompt: string,\\n fallback: T,\\n ) => Promise<T>;\\n // Drop-in for <img>: `<Image src=\u2026 alt=\u2026 />`. See AGENTS.md.\\n Image: React.ElementType<React.ComponentProps<\\"img\\">>;\\n}\\n\\n// See AGENTS.md for the design rules (em-based sizing, brand CSS\\n// variables), the lifecycle props, and how to write an async,\\n// backend-backed component.\\nexport default function __GS_PASCAL__(_props: Props): React.ReactElement {\\n return (\\n <div\\n style={{\\n padding: \\"1em\\",\\n border: \\"1px solid var(--color-border-default)\\",\\n borderRadius: \\"var(--radius-lg)\\",\\n background: \\"var(--color-surface)\\",\\n color: \\"var(--color-foreground)\\",\\n fontFamily: \\"var(--font-primary)\\",\\n }}\\n >\\n <strong>__GS_NAME__</strong> \u2014 hello from your component!\\n </div>\\n );\\n}\\n","component/manifest.json":"{\\n \\"name\\": \\"__GS_NAME__\\",\\n \\"displayName\\": \\"__GS_DISPLAY_NAME__\\",\\n \\"description\\": \\"Renders the __GS_NAME__ widget.\\",\\n \\"displayMode\\": \\"inline\\",\\n \\"inputSchema\\": {\\n \\"type\\": \\"object\\",\\n \\"properties\\": {}\\n }\\n}\\n","root/.gitignore":"node_modules/\\ncomponents/*/bundle.js\\ncomponents/*/.gssync.json\\n*.tsbuildinfo\\n.DS_Store\\n","root/.gsrc":"{\\n \\"store\\": \\"__GS_STORE__\\"\\n}\\n","root/AGENTS.md":"# AGENTS.md\\n\\n> **Do not edit \u2014 auto-generated by the GreatStore CLI v__GS_VERSION__.**\\n> This file is rewritten by `gs apps init`, so any changes you make here\\n> will be overwritten. If this version trails your installed CLI, re-run\\n> `gs apps init` to refresh it. Put project-specific notes in another file.\\n\\nGuidance for AI coding agents working on the components in this project.\\n`CLAUDE.md` and `GEMINI.md` are symlinks to this file.\\n\\nThese components render inside arbitrary publisher websites (the embed\\nwidget mounts on a host page) as well as the GreatStore storefront. You\\ncontrol neither the host page\'s base font size nor its color scheme, and\\nthe store owner controls the look from GreatStore theme settings. The\\nrules below keep components portable across both.\\n\\n## Design requirements\\n\\n### Never use `rem` for fonts and sizing \u2014 always use `em`\\n\\n`rem` resolves against the host page\'s root font size, which is\\narbitrary and outside our control. A host that sets `html { font-size:\\n8px }` (or 200%) will shrink or blow up every `rem`-based dimension.\\n`em` resolves against the component\'s own font size, so it stays\\nself-consistent wherever the component is mounted.\\n\\nUse `em` for font sizes, padding, margins, gaps, widths, heights,\\nand any other length. Borders may stay in `px` (hairlines should not\\nscale with text).\\n\\n```tsx\\n// Bad \u2014 breaks on hosts with a non-default root font size\\n<div style={{ padding: \\"1rem\\", fontSize: \\"0.875rem\\" }} />\\n\\n// Good\\n<div style={{ padding: \\"1em\\", fontSize: \\"0.875em\\" }} />\\n```\\n\\n### Don\'t hardcode colors, fonts, or corner radius \u2014 use GreatStore brand variables\\n\\nThe store owner themes the assistant from GreatStore settings. Hardcoded\\nvalues ignore that and make the component clash with the rest of the\\nstore. Read from the CSS variables GreatStore injects on the surface\\ninstead, so the component restyles itself when the theme changes.\\n\\nAvailable variables:\\n\\n| Purpose | Variable |\\n| --- | --- |\\n| Surface background | `--color-surface` |\\n| Secondary surface | `--color-surface-secondary` |\\n| Accent surface | `--color-surface-accent` |\\n| Hover surface | `--color-surface-hover` |\\n| Foreground text | `--color-foreground` |\\n| Secondary text | `--color-foreground-secondary` |\\n| Muted text | `--color-foreground-muted` |\\n| Accent text | `--color-foreground-accent` |\\n| Border | `--color-border-default` |\\n| Focus border | `--color-border-focus` |\\n| Primary / brand | `--color-primary` |\\n| Text on primary | `--color-primary-foreground` |\\n| Primary hover | `--color-primary-hover` |\\n| Primary muted | `--color-primary-muted` |\\n| Text on primary muted | `--color-primary-muted-foreground` |\\n| Primary tint | `--color-primary-tint` |\\n| Link | `--color-link` |\\n| Font family | `--font-primary` |\\n| Secondary font family | `--font-secondary` |\\n| Corner radius (scale) | `--radius-xs` \u2026 `--radius-4xl`, `--radius-pill` |\\n\\nThe store owner can set a secondary font family in their GreatStore\\ntheme settings, exposed as `--font-secondary` (it falls back to\\n`--font-primary` when unset). Reach for it to add a tasteful second\\nlayer of typography \u2014 pair `--font-primary` for body copy with\\n`--font-secondary` for headings, prices, or other accents \u2014 so the\\ncomponent reflects the store\'s full type system instead of a single\\nface.\\n\\n```tsx\\n// Bad \u2014 hardcoded, ignores the store\'s theme\\n<button style={{ background: \\"#4f46e5\\", borderRadius: 8, fontFamily: \\"Inter\\" }} />\\n\\n// Good\\n<button\\n style={{\\n background: \\"var(--color-primary)\\",\\n color: \\"var(--color-primary-foreground)\\",\\n borderRadius: \\"var(--radius-lg)\\",\\n fontFamily: \\"var(--font-primary)\\",\\n }}\\n/>\\n```\\n\\nProvide a sensible fallback only when a value might be absent, e.g.\\n`var(--color-primary, currentColor)`.\\n\\n## Component props\\n\\nEach component receives its tool args (the fields you declare in\\n`manifest.json#inputSchema.properties`) plus these GreatStore-injected\\nlifecycle props, which are always present:\\n\\n| Prop | What it does |\\n| --- | --- |\\n| `onSendMessage(text)` | Send text into the chat as if the shopper typed it. |\\n| `onCallTool(name, args)` | Chain into another remote-component tool by name. |\\n| `onUpdateModelContext(context)` | Inject invisible background context for the model (selected variant, configured options, current step). Replaces the prior value \u2014 never appends; pass `\\"\\"` to clear. Read on the next chat turn. Use it when the assistant should *know* in-component state without a visible message; use `onSendMessage` when you want a turn to happen now. |\\n| `onShowLightbox({ src, originRect? })` | Expand an image in the chat\'s shared full-screen lightbox \u2014 an on-brand zoom overlay your component can\'t render itself (it\'s boxed inside its own bounds and shadow root). Pass the image `src`; for a smooth zoom, also pass the clicked element\'s `getBoundingClientRect()` as `originRect` (omit it and the image grows from the viewport centre). |\\n| `onGenerateStructuredContent(schema, prompt, fallback)` | Ask the store\'s assistant for content matching a JSON Schema (or a Zod schema); resolves to the generated object. Personalized to the shopper. Works the same in the conversation on the storefront and every embed. Best inside an async component that builds its render from the generated payload \u2014 `await` it, then return the JSX. `fallback` is **required**: a schema-shaped object you supply that the component preview renders (so a generation-driven component previews without a live store). It\'s validated against the schema and throws if the two don\'t line up. |\\n| `onClose()` | Dismiss the host slot. Over-input clears the overlay, fullscreen reverts the pane, inline is a no-op. |\\n| `Image` | A drop-in for `<img>`: render `<Image src=\u2026 alt=\u2026 />` instead of `<img>` and your images are automatically served at the right size for the store. Takes the same props as `<img>` (`src`, `alt`, `style`, `loading`, `onClick`, \u2026). Previewing the component outside the store? Pass `Image={\\"img\\"}` (or your own component) to render a plain image. |\\n\\n## Async components (backend-backed, render-blocking data)\\n\\nIf a component must load data from a backend/API before it can render\\ncorrectly, make it async \u2014 don\'t render an empty shell and fetch in a\\n`useEffect`. Set `\\"async\\": true` in `manifest.json` and export an async\\ndefault. GreatStore waits for your promise (showing a normal loading\\nstate, so you don\'t render your own placeholder), then renders what it\\nresolves to. Components that render purely from their props stay\\nsynchronous.\\n\\nA thrown error is a **retry signal**: the in-store AI sees it and\\nusually re-calls the tool. So only throw when a *different* call could\\nhelp:\\n\\n1. `await` the backend call, then return the finished JSX.\\n2. Validate the AI-passed props first and throw on bad input \u2014 the AI\\n can fix the args and retry. (Don\'t validate the API\'s *output* and\\n throw: the AI can\'t fix the backend, it\'ll just loop.)\\n3. Broadcast a backend failure ONLY when retrying differently could\\n succeed, and say what to change (e.g. empty search \u2192 \\"try a broader\\n keyword\\"). For idempotent failures (500, timeout, missing record)\\n re-running the same call changes nothing \u2014 render a graceful fallback\\n instead of throwing.\\n\\n```tsx\\nexport default async function Example(props: Props) {\\n if (!props.query?.trim()) throw new Error(\\"missing required prop: query\\");\\n const res = await fetch(`/api/search?q=${encodeURIComponent(props.query)}`);\\n if (res.ok) {\\n const { results } = await res.json();\\n if (results.length === 0)\\n throw new Error(`no results for \\"${props.query}\\" \u2014 try a broader keyword`);\\n return <ul>{/* render results */}</ul>;\\n }\\n return <p>Couldn\'t load results right now.</p>; // idempotent: don\'t throw\\n}\\n```\\n","root/README.md":"# GreatStore components\\n\\nCustom React components published to your GreatStore tenant. Each\\ncomponent lives in its own folder under `components/`.\\n\\n```\\nnpm install\\ngs apps init <component_name> # add a new component\\ngs apps build # builds every components/<name>/bundle.js\\ngs apps push # uploads every changed component as a draft\\ngs apps publish <component_name> # promote a specific component to live\\n```\\n\\n- `gs apps push` (no args) hashes each component and only uploads the ones\\n that have changed since the last sync.\\n- `gs apps pull` (no args) refreshes every remote component into\\n `components/<name>/`. Components with unsaved local edits are skipped\\n with a warning; pass `--force` to overwrite.\\n\\nSee `AGENTS.md` for the design rules every component must follow\\n(em-based sizing, brand CSS variables) \u2014 it doubles as guidance for AI\\ncoding agents (`CLAUDE.md` / `GEMINI.md` symlink to it).\\n","root/package.json":"{\\n \\"name\\": \\"greatstore-components\\",\\n \\"version\\": \\"0.0.1\\",\\n \\"private\\": true,\\n \\"type\\": \\"module\\",\\n \\"scripts\\": {\\n \\"build\\": \\"gs apps build\\",\\n \\"push\\": \\"gs apps build && gs apps push\\"\\n },\\n \\"dependencies\\": {\\n \\"react\\": \\"^19.0.0\\",\\n \\"react-dom\\": \\"^19.0.0\\"\\n },\\n \\"devDependencies\\": {\\n \\"@types/react\\": \\"^19.0.0\\",\\n \\"@types/react-dom\\": \\"^19.0.0\\",\\n \\"@vitejs/plugin-react\\": \\"^4.3.0\\",\\n \\"typescript\\": \\"^5.6.0\\",\\n \\"vite\\": \\"^5.4.0\\"\\n }\\n}\\n","root/tsconfig.json":"{\\n \\"compilerOptions\\": {\\n \\"target\\": \\"ES2022\\",\\n \\"module\\": \\"ESNext\\",\\n \\"moduleResolution\\": \\"Bundler\\",\\n \\"jsx\\": \\"react-jsx\\",\\n \\"lib\\": [\\"ES2022\\", \\"DOM\\"],\\n \\"strict\\": true,\\n \\"esModuleInterop\\": true,\\n \\"skipLibCheck\\": true,\\n \\"isolatedModules\\": true,\\n \\"noEmit\\": true\\n },\\n \\"include\\": [\\"components/**/component.tsx\\", \\"vite.config.ts\\"]\\n}\\n","root/vite.config.ts":"import { defineConfig } from \\"vite\\";\\nimport react from \\"@vitejs/plugin-react\\";\\n\\n// Real builds happen in `gs build` (one Vite invocation per\\n// component, externals + runtime shim paths owned by the CLI). This\\n// file exists only so editors / language servers can resolve the\\n// React plugin when inspecting components/*/component.tsx.\\nexport default defineConfig({\\n plugins: [react()],\\n});\\n"}'),ve)}var ft={name:"__GS_NAME__",pascalName:"__GS_PASCAL__",displayName:"__GS_DISPLAY_NAME__",store:"__GS_STORE__",version:"__GS_VERSION__"};function mt(e,t){let n=e;for(let o of Object.keys(ft)){let s=t[o];s!==void 0&&(n=n.split(ft[o]).join(s))}let r=n.match(/__GS_[A-Z_]+__/);if(r)throw new Error(`internal: template placeholder ${r[0]} was not provided`);return n}var gt=/^[a-z][a-z0-9_]*$/;function yt(e){let t=e.positional[0];if(t!==void 0&&!gt.test(t))throw new Error(`Invalid component name: "${t}" (must match ${gt}).`);let n=m(e.flags,"force"),r=h(e.flags,"store"),o=h(e.flags,"out")??".",s=k.resolve(o),i=nr(s),a;if(i){if(r!==void 0)throw new Error(`Project at ${s} is already pinned to a store via .gsrc. Drop --store; a project folder ships to exactly one store.`);$({cwd:s})}else if(a=r!==void 0?ee(r):ce()??void 0,a===void 0){let u=t?`gs apps init ${t} --store <slug>`:"gs apps init --store <slug>";throw new Error(`--store <slug> is required when scaffolding a new project root. Run \`${u}\`.`)}let l=rr(s,i,n,{store:a});if(!t){let u=[];i?(u.push(`Updated GreatStore project root in ${s}.`),l.length>0?u.push("",`Added: ${l.join(", ")}`):u.push("","Already up to date \u2014 nothing to add.")):u.push(`Scaffolded GreatStore project root in ${s}.`),u.push("","Next steps:",` cd ${k.relative(process.cwd(),s)||"."}`," npm install"," gs apps init <component_name> # add your first component",""),process.stdout.write(u.join(`
82
+ `));return}let c=k.join(s,"components",t);ir(c,t,n);let p=k.relative(process.cwd(),s)||".";process.stdout.write([`Added component "${t}" at components/${t}/.`,...i&&l.length>0?["",`Also added to the project root: ${l.join(", ")}`]:[],"","Next steps:",...i?[]:[` cd ${p}`," npm install"],` # edit components/${t}/component.tsx and manifest.json`," gs apps build"," gs apps push",""].join(`
83
+ `))}function nr(e){return g.existsSync(k.join(e,"package.json"))&&g.existsSync(k.join(e,".gsrc"))}function rr(e,t,n,r){if(g.mkdirSync(e,{recursive:!0}),!t&&!n&&g.readdirSync(e).filter(a=>a!==".gsrc").length>0)throw new Error(`Refusing to scaffold project root into non-empty directory ${e}. Pass --force to override.`);let o=t?cr():ar({store:r.store}),s=sr(e,o,n);return g.mkdirSync(k.join(e,"components"),{recursive:!0}),s}var or=new Set(["AGENTS.md"]);function sr(e,t,n){let r=[];for(let[o,s]of t){let i=k.join(e,o);g.mkdirSync(k.dirname(i),{recursive:!0});let a=g.existsSync(i);if(!n&&a&&!or.has(o))continue;let l=!a||g.readFileSync(i,"utf8")!==s;g.writeFileSync(i,s),l&&r.push(o)}for(let o of["CLAUDE.md","GEMINI.md"]){let s=k.join(e,o);n&&ht(s)&&g.rmSync(s),ht(s)||(g.symlinkSync("AGENTS.md",s),r.push(o))}return r}function ht(e){try{return g.lstatSync(e),!0}catch{return!1}}function ir(e,t,n){if(g.existsSync(e)&&!n&&g.readdirSync(e).length>0)throw new Error(`Refusing to overwrite existing components/${t}/. Pass --force to override.`);g.mkdirSync(e,{recursive:!0});for(let[r,o]of lr(t))g.writeFileSync(k.join(e,r),o)}function Oe(e,t,n=new Set){let r=dt();return Object.entries(r).filter(([o])=>o.startsWith(e)).map(([o,s])=>[o.slice(e.length),s]).filter(([o])=>!n.has(o)).map(([o,s])=>[o,mt(s,t)])}function ar(e){if(!e.store)throw new Error("internal: rootFiles called without a store slug");return Oe("root/",{store:e.store,version:N})}function cr(){return Oe("root/",{version:N},new Set([".gsrc"]))}function lr(e){return Oe("component/",{name:e,pascalName:pr(e),displayName:ur(e)})}function ur(e){let t=e.split("_").filter(Boolean);if(t.length===0)return e;let n=t[0];return n.charAt(0).toUpperCase()+n.slice(1)+(t.length>1?" "+t.slice(1).join(" "):"")}function pr(e){return e.split(/[_-]/).filter(Boolean).map(t=>t[0]?.toUpperCase()+t.slice(1)).join("")}import*as b from"fs";import*as w from"path";import{createRequire as kr}from"module";import*as jt from"fs";import*as U from"path";import{createRequire as fr}from"module";import*as xe from"path";function St(e,t,n){let r=vt(e);if(!r)return{ok:!1,reason:"couldn't check props against the manifest \u2014 `typescript` isn't installed in this project (run `npm install`)"};try{let o=r.createSourceFile(t,n,r.ScriptTarget.Latest,!0,r.ScriptKind.TSX),s=mr(r,o);return s?yr(r,o,s):{ok:!1,reason:"couldn't find a default-exported component function to check props against \u2014 export the component as `export default function \u2026`"}}catch(o){return{ok:!1,reason:`couldn't check props against the manifest \u2014 ${xe.basename(t)} could not be parsed (${o.message})`}}}function bt(e,t,n){let r=vt(e);if(!r)return!1;try{let o=r.createSourceFile(t,n,r.ScriptTarget.Latest,!0,r.ScriptKind.TSX),s=!1,i=a=>{if(!s){if(dr(r,a)){s=!0;return}r.forEachChild(a,i)}};return i(o),s}catch{return!1}}function dr(e,t){if(e.isPropertyAccessExpression(t))return wt(e,t.expression)&&t.name.text==="GreatStore";if(e.isElementAccessExpression(t)){let n=t.argumentExpression;return wt(e,t.expression)&&e.isStringLiteralLike(n)&&n.text==="GreatStore"}return!1}function wt(e,t){return e.isIdentifier(t)&&(t.text==="window"||t.text==="globalThis")}function vt(e){let t=fr(xe.join(e,"package.json"));try{return t("typescript")}catch{return null}}function mr(e,t){let n=null;for(let o of t.statements){if(e.isFunctionDeclaration(o)&&gr(e,o))return o;e.isExportAssignment(o)&&!o.isExportEquals&&(n=o.expression)}if(!n)return null;let r=xt(e,n);return e.isArrowFunction(r)||e.isFunctionExpression(r)?r:e.isIdentifier(r)?hr(e,t,r.text):null}function gr(e,t){return t.modifiers?.some(n=>n.kind===e.SyntaxKind.DefaultKeyword)??!1}function xt(e,t){let n=t;for(;e.isParenthesizedExpression(n)||e.isAsExpression(n)||e.isSatisfiesExpression(n);)n=n.expression;return n}function hr(e,t,n){for(let r of t.statements){if(e.isFunctionDeclaration(r)&&r.name?.text===n)return r;if(e.isVariableStatement(r))for(let o of r.declarationList.declarations){if(!e.isIdentifier(o.name)||o.name.text!==n||!o.initializer)continue;let s=xt(e,o.initializer);if(e.isArrowFunction(s)||e.isFunctionExpression(s))return s}}return null}function yr(e,t,n){let r=n.parameters[0];if(!r)return{ok:!0,props:{names:[],open:!1}};if(r.type){let o=Ie(e,t,r.type,new Set);if(o)return{ok:!0,props:o}}return e.isObjectBindingPattern(r.name)?{ok:!0,props:wr(e,r.name)}:{ok:!1,reason:"couldn't check props against the manifest \u2014 declare the component's props as a local `interface`/`type` or destructure them in the signature"}}function Ie(e,t,n,r){if(e.isTypeLiteralNode(n))return Pt(e,n.members);if(e.isTypeReferenceNode(n)&&e.isIdentifier(n.typeName))return kt(e,t,n.typeName.text,r);if(e.isIntersectionTypeNode(n)){let o=n.types.map(s=>Ie(e,t,s,r));return o.every(s=>s===null)?null:Ct(o.map(s=>s??{names:[],open:!0}))}return null}function kt(e,t,n,r){if(r.has(n))return{names:[],open:!1};r.add(n);for(let o of t.statements){if(e.isInterfaceDeclaration(o)&&o.name.text===n){let s=Pt(e,o.members),i=(o.heritageClauses??[]).flatMap(a=>a.types.map(l=>e.isIdentifier(l.expression)?kt(e,t,l.expression.text,r)??{names:[],open:!0}:{names:[],open:!0}));return Ct([s,...i])}if(e.isTypeAliasDeclaration(o)&&o.name.text===n)return Ie(e,t,o.type,r)}return null}function Pt(e,t){let n=[],r=!1;for(let o of t){if(e.isIndexSignatureDeclaration(o)){r=!0;continue}if(!e.isPropertySignature(o)&&!e.isMethodSignature(o))continue;let s=$t(e,o.name);if(s===null){r=!0;continue}n.push(s)}return{names:n,open:r}}function wr(e,t){let n=[],r=!1;for(let o of t.elements){if(o.dotDotDotToken){r=!0;continue}let s=o.propertyName??o.name,i=$t(e,s);i===null?r=!0:n.push(i)}return{names:n,open:r}}function $t(e,t){return e.isIdentifier(t)||e.isStringLiteral(t)?t.text:null}function Ct(e){let t=[],n=!1;for(let r of e){for(let o of r.names)t.includes(o)||t.push(o);n||=r.open}return{names:t,open:n}}function Rt(e){let{root:t,name:n}=e,r=U.join(t,"components",n),o=e.manifestPath??U.join(r,"manifest.json"),s=e.sourcePath??U.join(r,"component.tsx"),i=At(t,o),a=At(t,s),l=[],c=null,p=Et(o);if(p===null)l.push({severity:"error",rule:"manifest/missing",file:i,message:"manifest not found."});else try{let P=JSON.parse(p);!P||typeof P!="object"||Array.isArray(P)?l.push({severity:"error",rule:"manifest/invalid",file:i,message:"manifest must be a JSON object."}):c=P}catch(P){l.push({severity:"error",rule:"manifest/invalid",file:i,message:`manifest is not valid JSON: ${P.message}`})}let u=Et(s),f=u===null?{ok:!1,reason:`couldn't check props against the manifest \u2014 ${a} not found`}:St(t,s,u),j=u===null?!1:bt(t,s,u);return{ctx:{name:n,manifestFile:i,sourceFile:a,manifest:c,props:f,usesWindowGreatStore:j},diagnostics:l}}function Et(e){try{return jt.readFileSync(e,"utf8")}catch{return null}}function At(e,t){let n=U.relative(e,t);return n.startsWith("..")?t:n.split(U.sep).join("/")}var _t=new Set(["onSendMessage","onCallTool","onClose","onUpdateModelContext","onShowLightbox","onGenerateStructuredContent","storeData","Image"]);var Tt=new Map([["onError",'prop `onError` is deprecated and no longer provided \u2014 prefer an async component to report failures. Drop the prop; see the "Async components" section in AGENTS.md for how to signal errors.']]);function Ot(e){if(!e.manifest)return[];let t=br(e.manifest.inputSchema);if(t===null)return[];if(!e.props.ok)return[{severity:"warning",rule:"props/not-analyzable",file:e.sourceFile,message:`${e.props.reason}.`}];if(e.props.props.open)return[];let n=new Set(e.props.props.names),r=new Set(t),o=[];for(let i of e.props.props.names){if(_t.has(i))continue;let a=Tt.get(i);if(a){o.push({severity:"warning",rule:"props/retired-lifecycle",file:e.sourceFile,message:a});continue}r.has(i)||o.push({severity:"warning",rule:"props/undeclared",file:e.sourceFile,message:`prop \`${i}\` is not declared in ${e.manifestFile}#inputSchema.properties, so nothing will ever pass it. Declare it in the schema, or drop it from the component.`})}let s=t.filter(i=>!n.has(i));return s.length>0&&o.push({severity:"error",rule:"props/missing",file:e.sourceFile,message:Sr(e.manifestFile,s)}),o}var Lt=8;function Sr(e,t){if(t.length===1){let[s]=t;return`${e} declares inputSchema field \`${s}\`, but the component does not accept a \`${s}\` prop. Add it to the component's props, or remove it from the schema.`}let n=t.slice(0,Lt).map(s=>`\`${s}\``).join(", "),r=t.length-Lt,o=r>0?`${n} (+${r} more)`:n;return`${e} declares ${t.length} inputSchema fields the component does not accept: ${o}. Add them to the component's props, or remove them from the schema.`}function br(e){if(!e||typeof e!="object")return null;let t=e.properties;return!t||typeof t!="object"||Array.isArray(t)?null:Object.keys(t)}var vr=["anyOf","oneOf","allOf","$ref","not"];function ke(e,t,n){if(Array.isArray(e)){e.forEach((s,i)=>ke(s,`${t}[${i}]`,n));return}if(!e||typeof e!="object")return;let r=e;for(let s of vr)s in r&&n.unionPaths.push(`${t}.${s}`);let o=r.properties;if(o&&typeof o=="object"&&!Array.isArray(o))for(let[s,i]of Object.entries(o))n.fields+=1,ke(i,`${t}.${s}`,n);"items"in r&&ke(r.items,`${t}[]`,n)}function It(e){let t=e.manifest?.inputSchema;if(!t||typeof t!="object")return[];let n={bytes:Buffer.byteLength(JSON.stringify(t),"utf8"),fields:0,unionPaths:[]};ke(t,"inputSchema",n);let r=[];if(n.unionPaths.length>0){let o=n.unionPaths.slice(0,3).join(", "),s=n.unionPaths.length>3?` (+${n.unionPaths.length-3} more)`:"";r.push(`uses ${o}${s} \u2014 declare exactly one type per field; accept alternate shapes in component code instead`)}return n.bytes>8192&&r.push(`is ${(n.bytes/1024).toFixed(1)} KB serialized (limit ${8192/1024} KB)`),n.fields>50&&r.push(`declares ${n.fields} fields (limit 50)`),r.length===0?[]:[{severity:"error",rule:"manifest/input-schema-too-complex",file:e.manifestFile,message:`inputSchema ${r.join("; ")}.
84
+ A schema this complex is usually a sign the component is overengineered, and the assistant will fill it unreliably or stop calling the tool altogether. Keep it to a small set of flat, single-type fields (one canonical name per concept \u2014 no aliases), and let component code handle formatting, fallbacks, and edge cases.`}]}function Ft(e){let t=e.manifest?.name;return typeof t!="string"||t===e.name?[]:[{severity:"error",rule:"manifest/name-mismatch",file:e.manifestFile,message:`manifest name "${t}" does not match folder name "${e.name}".`}]}function Nt(e){return e.usesWindowGreatStore?[{severity:"warning",rule:"globals/window-greatstore",file:e.sourceFile,message:"this component reads `window.GreatStore`, the host-page embed API. Components should interact with GreatStore through their injected lifecycle props (`onSendMessage`, `onCallTool`, `onGenerateStructuredContent`, \u2026) instead \u2014 those are wired to the surface the component is mounted in."}]:[]}function pe(e){return e.filter(t=>t.severity==="error")}function Fe(e){return e.filter(t=>t.severity==="warning")}function fe(e){return`${e.severity==="error"?"error":"warning"} ${e.file}: ${e.message}`}var xr=[Ft,It,Ot,Nt];function Pe(e){let{ctx:t,diagnostics:n}=Rt(e);for(let r of xr)n.push(...r(t));return{diagnostics:n,ok:pe(n).length===0}}var W="components";async function Bt(e){let t=process.cwd();if(!b.existsSync(w.join(t,"package.json"))||!b.existsSync(w.join(t,W)))throw new Error(`\`gs apps build\` must run from a project root (contains \`package.json\` and \`${W}/\`). Current dir: ${t}`);let n=Pr(t);if(n.length===0){process.stdout.write(`(no components in ./${W} \u2014 run \`gs apps init <name>\` to add one)
85
+ `);return}let r=e.positional[0],o=r?n.filter(p=>p===r):n;if(r&&o.length===0)throw new Error(`No component named "${r}" in ./${W}`);let s=[],i=[];for(let p of o){let u=Pe({root:t,name:p});for(let f of u.diagnostics)process.stdout.write(` ${fe(f)}
86
86
  `);(u.ok?i:s).push(p)}if(i.length===0){process.stdout.write(`
87
87
  Nothing built \u2014 fix the errors above.
88
- `),process.exitCode=1;return}let{build:a,reactPlugin:l,transformWithEsbuild:c}=await Pr(t);for(let p of i){let u=w.join(t,K,p),f=w.join(u,"bundle.js");await a({plugins:[l()],logLevel:"warn",build:{lib:{entry:w.join(u,"component.tsx"),formats:["es"],fileName:()=>"bundle.js"},outDir:u,emptyOutDir:!1,rollupOptions:{external:["react","react-dom","react/jsx-runtime"],output:{entryFileNames:"bundle.js",paths:{react:"/assets/remote-components/_runtime.js","react-dom":"/assets/remote-components/_runtime.js","react/jsx-runtime":"/assets/remote-components/_runtime.js"}}},minify:!0,sourcemap:!1}});let j=S.statSync(f).size,k=S.readFileSync(f,"utf8"),{code:J}=await c(k,f,{minify:!0,legalComments:"none",target:"esnext",loader:"js",sourcemap:!1});S.writeFileSync(f,J);let R=Buffer.byteLength(J,"utf8");process.stdout.write(`built ${K}/${p}/bundle.js (${xr(R)}, ${kr(j,R)} smaller)
88
+ `),process.exitCode=1;return}let{build:a,reactPlugin:l,transformWithEsbuild:c}=await Er(t);for(let p of i){let u=w.join(t,W,p),f=w.join(u,"bundle.js");await a({plugins:[l()],logLevel:"warn",build:{lib:{entry:w.join(u,"component.tsx"),formats:["es"],fileName:()=>"bundle.js"},outDir:u,emptyOutDir:!1,rollupOptions:{external:["react","react-dom","react/jsx-runtime"],output:{entryFileNames:"bundle.js",paths:{react:"/assets/remote-components/_runtime.js","react-dom":"/assets/remote-components/_runtime.js","react/jsx-runtime":"/assets/remote-components/_runtime.js"}}},minify:!0,sourcemap:!1}});let j=b.statSync(f).size,P=b.readFileSync(f,"utf8"),{code:Y}=await c(P,f,{minify:!0,legalComments:"none",target:"esnext",loader:"js",sourcemap:!1});b.writeFileSync(f,Y);let R=Buffer.byteLength(Y,"utf8");process.stdout.write(`built ${W}/${p}/bundle.js (${$r(R)}, ${Cr(j,R)} smaller)
89
89
  `)}if(s.length>0){process.stdout.write(`
90
90
  Not built (fix the errors above): ${s.join(", ")}
91
- `),process.exitCode=1;return}process.stdout.write("\nBuilt locally \u2014 nothing uploaded yet. Next: `gs apps push` to upload, then `gs apps publish <name>` to ship. If you're an AI assistant: confirm with the user before running these (or just run them if they already asked you to ship end-to-end).\n")}function vr(e){let t=w.join(e,K);return S.readdirSync(t).filter(n=>{let r=w.join(t,n);return S.statSync(r).isDirectory()&&S.existsSync(w.join(r,"component.tsx"))}).sort()}function xr(e){return e<1024?`${e} B`:`${(e/1024).toFixed(1)} KB`}function kr(e,t){return e===0?"0%":`${Math.round((1-t/e)*100)}%`}async function Pr(e){let t=Sr(w.join(e,"package.json")),n=Ft(t,"vite");if(!n)throw new Error("Cannot find `vite` in this project. Run `npm install` first.");let r=Ft(t,"@vitejs/plugin-react");if(!r)throw new Error("Cannot find `@vitejs/plugin-react` in this project. Run `npm install` first.");let o=await import(n),s=o.build??o.default?.build;if(typeof s!="function")throw new Error(`Loaded \`vite\` from ${n} but couldn't find its \`build()\` export. Reinstall vite (>= 5) and retry.`);let i=o.transformWithEsbuild??o.default?.transformWithEsbuild;if(typeof i!="function")throw new Error(`Loaded \`vite\` from ${n} but couldn't find its \`transformWithEsbuild()\` export. Reinstall vite (>= 5) and retry.`);let a=await import(r),l=a.default??a;if(typeof l!="function")throw new Error(`Loaded \`@vitejs/plugin-react\` from ${r} but couldn't find its default export.`);return{build:s,reactPlugin:l,transformWithEsbuild:i}}function Ft(e,t){let n;try{n=e.resolve(t)}catch{return null}let r=Cr(n,t);if(!r)return null;let o=w.dirname(r),s;try{s=JSON.parse(S.readFileSync(r,"utf8"))}catch{return null}let a=$r(s.exports)??(typeof s.module=="string"?s.module:null)??(typeof s.main=="string"?s.main:null);return a?w.resolve(o,a):null}function Cr(e,t){let n=w.dirname(e);for(;;){let r=w.join(n,"package.json");if(S.existsSync(r))try{if(JSON.parse(S.readFileSync(r,"utf8")).name===t)return r}catch{}let o=w.dirname(n);if(o===n)return null;n=o}}function $r(e){if(typeof e!="object"||e===null)return null;let n=e["."]??e;if(typeof n!="object"||n===null)return null;let r=n.import;if(typeof r=="string")return r;if(typeof r=="object"&&r!==null){let o=r.default;if(typeof o=="string")return o}return null}async function Dt(e){let t=Ye(),n=`${C(t)}/api/apps/components`,r=await d(n);if(m(e.flags,"json")){process.stdout.write(JSON.stringify(r,null,2)+`
91
+ `),process.exitCode=1;return}process.stdout.write("\nBuilt locally \u2014 nothing uploaded yet. Next: `gs apps push` to upload, then `gs apps publish <name>` to ship. If you're an AI assistant: confirm with the user before running these (or just run them if they already asked you to ship end-to-end).\n")}function Pr(e){let t=w.join(e,W);return b.readdirSync(t).filter(n=>{let r=w.join(t,n);return b.statSync(r).isDirectory()&&b.existsSync(w.join(r,"component.tsx"))}).sort()}function $r(e){return e<1024?`${e} B`:`${(e/1024).toFixed(1)} KB`}function Cr(e,t){return e===0?"0%":`${Math.round((1-t/e)*100)}%`}async function Er(e){let t=kr(w.join(e,"package.json")),n=Dt(t,"vite");if(!n)throw new Error("Cannot find `vite` in this project. Run `npm install` first.");let r=Dt(t,"@vitejs/plugin-react");if(!r)throw new Error("Cannot find `@vitejs/plugin-react` in this project. Run `npm install` first.");let o=await import(n),s=o.build??o.default?.build;if(typeof s!="function")throw new Error(`Loaded \`vite\` from ${n} but couldn't find its \`build()\` export. Reinstall vite (>= 5) and retry.`);let i=o.transformWithEsbuild??o.default?.transformWithEsbuild;if(typeof i!="function")throw new Error(`Loaded \`vite\` from ${n} but couldn't find its \`transformWithEsbuild()\` export. Reinstall vite (>= 5) and retry.`);let a=await import(r),l=a.default??a;if(typeof l!="function")throw new Error(`Loaded \`@vitejs/plugin-react\` from ${r} but couldn't find its default export.`);return{build:s,reactPlugin:l,transformWithEsbuild:i}}function Dt(e,t){let n;try{n=e.resolve(t)}catch{return null}let r=Ar(n,t);if(!r)return null;let o=w.dirname(r),s;try{s=JSON.parse(b.readFileSync(r,"utf8"))}catch{return null}let a=jr(s.exports)??(typeof s.module=="string"?s.module:null)??(typeof s.main=="string"?s.main:null);return a?w.resolve(o,a):null}function Ar(e,t){let n=w.dirname(e);for(;;){let r=w.join(n,"package.json");if(b.existsSync(r))try{if(JSON.parse(b.readFileSync(r,"utf8")).name===t)return r}catch{}let o=w.dirname(n);if(o===n)return null;n=o}}function jr(e){if(typeof e!="object"||e===null)return null;let n=e["."]??e;if(typeof n!="object"||n===null)return null;let r=n.import;if(typeof r=="string")return r;if(typeof r=="object"&&r!==null){let o=r.default;if(typeof o=="string")return o}return null}async function Ht(e){let t=Ze(),n=`${x(t)}/api/apps/components`,r=await d(n);if(m(e.flags,"json")){process.stdout.write(JSON.stringify(r,null,2)+`
92
92
  `);return}if(r.components.length===0){process.stdout.write(`(no components in ${t})
93
- `);return}let o=r.components.map(a=>({name:a.name,draft:a.draft?`v${a.draft.version}`:"\u2014",live:a.live?`v${a.live.version}`:"\u2014",updated:a.live?.updatedAt??a.draft?.updatedAt??"",permalink:a.permalink??""})),s={name:Math.max(4,...o.map(a=>a.name.length)),draft:Math.max(5,...o.map(a=>a.draft.length)),live:Math.max(4,...o.map(a=>a.live.length)),updated:Math.max(7,...o.map(a=>a.updated.length))},i=`${U("NAME",s.name)} ${U("DRAFT",s.draft)} ${U("LIVE",s.live)} ${U("UPDATED",s.updated)} LINK`;process.stdout.write(i+`
94
- `);for(let a of o)process.stdout.write(`${U(a.name,s.name)} ${U(a.draft,s.draft)} ${U(a.live,s.live)} ${U(a.updated,s.updated)} ${a.permalink}
95
- `)}function U(e,t){return e.length>=t?e:e+" ".repeat(t-e.length)}import*as O from"fs";import*as W from"path";import*as Bt from"crypto";import*as G from"fs";import*as Z from"path";var Ht=".gssync.json";function le(e){return Bt.createHash("sha256").update(e).digest("hex")}function Ie(e){return G.existsSync(e)?le(G.readFileSync(e,"utf8")):null}function ee(e){let t=Ie(Z.join(e,"manifest.json"));if(t===null)throw new Error(`Missing manifest.json in ${e}`);return{manifestHash:t,sourceHash:Ie(Z.join(e,"component.tsx")),bundleHash:Ie(Z.join(e,"bundle.js"))}}function ke(e){let t=Z.join(e,Ht);if(!G.existsSync(t))return null;try{let n=JSON.parse(G.readFileSync(t,"utf8"));return typeof n.version=="number"&&typeof n.manifestHash=="string"&&typeof n.sourceHash=="string"?{version:n.version,manifestHash:n.manifestHash,sourceHash:n.sourceHash,...typeof n.bundleHash=="string"?{bundleHash:n.bundleHash}:{}}:null}catch{return null}}function ue(e,t){G.writeFileSync(Z.join(e,Ht),JSON.stringify(t,null,2)+`
96
- `)}function Mt(e,t){let n=Er(e);if(!n)return!1;if(t===null||n.manifestHash!==t.manifestHash)return!0;let r=n.sourceHash??"",o=t.sourceHash??"";return r!==o}function Er(e){try{return ee(e)}catch{return null}}async function Ut(e){let t=E(),n=m(e.flags,"force"),r=e.positional,o=process.cwd();if(r.length===0||r.length===1&&r[0]==="*")return Ar({slug:t,root:o,args:e,force:n});if(r.length>1&&h(e.flags,"version"))throw new Error("--version is per-component; pass it together with a single `gs apps pull <name>`.");Vt(o);let s=Kt(e),i=[];for(let a of r){let l=await qt({slug:t,componentDir:W.join(o,"components",a),name:a,revisionQuery:s,force:n});i.push(l),Wt(l,n)}i.length>1&&Gt(i,t),i.some(a=>a.status==="failed")&&(process.exitCode=1)}async function Ar(e){let{slug:t,root:n,args:r,force:o}=e;if(h(r.flags,"version"))throw new Error("--version is per-component; pass it together with `gs apps pull <name>`.");Vt(n);let s=Kt(r),i=`${C(t)}/api/apps/components`,a=await d(i);if(a.components.length===0){process.stdout.write(`(no components in ${t})
97
- `);return}let l=[];for(let c of a.components){let p=W.join(n,"components",c.name),u=await qt({slug:t,componentDir:p,name:c.name,revisionQuery:s===""&&c.live===null?"?revision=draft":s,force:o});l.push(u),Wt(u,o)}Gt(l,t),l.some(c=>c.status==="failed")&&(process.exitCode=1)}function Gt(e,t){let n=e.filter(i=>i.status==="pulled").length,r=e.filter(i=>i.status==="skipped").length,o=e.filter(i=>i.status==="failed").length,s=[`${n} pulled`,`${r} skipped`];o>0&&s.push(`${o} failed`),process.stdout.write(`
93
+ `);return}let o=r.components.map(a=>({name:a.name,draft:a.draft?`v${a.draft.version}`:"\u2014",live:a.live?`v${a.live.version}`:"\u2014",updated:a.live?.updatedAt??a.draft?.updatedAt??"",permalink:a.permalink??""})),s={name:Math.max(4,...o.map(a=>a.name.length)),draft:Math.max(5,...o.map(a=>a.draft.length)),live:Math.max(4,...o.map(a=>a.live.length)),updated:Math.max(7,...o.map(a=>a.updated.length))},i=`${G("NAME",s.name)} ${G("DRAFT",s.draft)} ${G("LIVE",s.live)} ${G("UPDATED",s.updated)} LINK`;process.stdout.write(i+`
94
+ `);for(let a of o)process.stdout.write(`${G(a.name,s.name)} ${G(a.draft,s.draft)} ${G(a.live,s.live)} ${G(a.updated,s.updated)} ${a.permalink}
95
+ `)}function G(e,t){return e.length>=t?e:e+" ".repeat(t-e.length)}import*as I from"fs";import*as X from"path";import*as Mt from"crypto";import*as q from"fs";import*as ne from"path";var Ut=".gssync.json";function V(e){return Mt.createHash("sha256").update(e).digest("hex")}function Ne(e){return q.existsSync(e)?V(q.readFileSync(e,"utf8")):null}function re(e){let t=Ne(ne.join(e,"manifest.json"));if(t===null)throw new Error(`Missing manifest.json in ${e}`);return{manifestHash:t,sourceHash:Ne(ne.join(e,"component.tsx")),bundleHash:Ne(ne.join(e,"bundle.js"))}}function oe(e){let t=ne.join(e,Ut);if(!q.existsSync(t))return null;try{let n=JSON.parse(q.readFileSync(t,"utf8"));return typeof n.version=="number"&&typeof n.manifestHash=="string"&&typeof n.sourceHash=="string"?{version:n.version,manifestHash:n.manifestHash,sourceHash:n.sourceHash,...typeof n.bundleHash=="string"?{bundleHash:n.bundleHash}:{}}:null}catch{return null}}function z(e,t){q.writeFileSync(ne.join(e,Ut),JSON.stringify(t,null,2)+`
96
+ `)}function Gt(e,t){let n=Rr(e);if(!n)return!1;if(t===null||n.manifestHash!==t.manifestHash)return!0;let r=n.sourceHash??"",o=t.sourceHash??"";return r!==o}function Rr(e){try{return re(e)}catch{return null}}async function qt(e){let t=$(),n=m(e.flags,"force"),r=e.positional,o=process.cwd();if(r.length===0||r.length===1&&r[0]==="*")return _r({slug:t,root:o,args:e,force:n});if(r.length>1&&h(e.flags,"version"))throw new Error("--version is per-component; pass it together with a single `gs apps pull <name>`.");Kt(o);let s=Wt(e),i=[];for(let a of r){let l=await Jt({slug:t,componentDir:X.join(o,"components",a),name:a,revisionQuery:s,force:n});i.push(l),zt(l,n)}i.length>1&&Vt(i,t),i.some(a=>a.status==="failed")&&(process.exitCode=1)}async function _r(e){let{slug:t,root:n,args:r,force:o}=e;if(h(r.flags,"version"))throw new Error("--version is per-component; pass it together with `gs apps pull <name>`.");Kt(n);let s=Wt(r),i=`${x(t)}/api/apps/components`,a=await d(i);if(a.components.length===0){process.stdout.write(`(no components in ${t})
97
+ `);return}let l=[];for(let c of a.components){let p=X.join(n,"components",c.name),u=await Jt({slug:t,componentDir:p,name:c.name,revisionQuery:s===""&&c.live===null?"?revision=draft":s,force:o});l.push(u),zt(u,o)}Vt(l,t),l.some(c=>c.status==="failed")&&(process.exitCode=1)}function Vt(e,t){let n=e.filter(i=>i.status==="pulled").length,r=e.filter(i=>i.status==="skipped").length,o=e.filter(i=>i.status==="failed").length,s=[`${n} pulled`,`${r} skipped`];o>0&&s.push(`${o} failed`),process.stdout.write(`
98
98
  ${s.join(", ")} (of ${e.length}) \u2190 ${t}
99
- `)}async function qt(e){let{slug:t,componentDir:n,name:r,revisionQuery:o,force:s}=e;if(!s&&O.existsSync(n)){let f=ke(n);if(Mt(n,f))return{name:r,status:"skipped",message:"local has uncommitted changes; pass --force to overwrite"}}let i=`${C(t)}/api/apps/components/${encodeURIComponent(r)}`,a;try{a=await d(`${i}${o}`)}catch(f){if(o===""&&jr(f))try{a=await d(`${i}?revision=draft`)}catch(j){return{name:r,status:"failed",message:j instanceof Error?j.message:String(j)}}else return{name:r,status:"failed",message:f instanceof Error?f.message:String(f)}}O.mkdirSync(n,{recursive:!0});let l=JSON.stringify(a.manifest,null,2)+`
100
- `;O.writeFileSync(W.join(n,"manifest.json"),l),O.writeFileSync(W.join(n,"bundle.js"),a.bundle);let c=["manifest.json","bundle.js"],p="";a.source!==null&&(O.writeFileSync(W.join(n,"component.tsx"),a.source),c.push("component.tsx"),p=le(a.source)),ue(n,{version:a.version,manifestHash:le(l),sourceHash:p,bundleHash:le(a.bundle)});let u=ee(n);return ue(n,{version:a.version,manifestHash:u.manifestHash,sourceHash:u.sourceHash??"",bundleHash:u.bundleHash??""}),{name:r,status:"pulled",version:a.version,wrote:c}}function Vt(e){O.mkdirSync(W.join(e,"components"),{recursive:!0})}function jr(e){return e instanceof N&&e.status===404}function Kt(e){let t=h(e.flags,"version");return t?`?version=${encodeURIComponent(t)}`:m(e.flags,"draft")?"?revision=draft":m(e.flags,"live")?"?revision=live":""}function Wt(e,t){switch(e.status){case"pulled":{let n=e.wrote?`{${e.wrote.join(", ")}}`:"";process.stdout.write(` pulled ${e.name} v${e.version} ${n}
99
+ `)}async function Jt(e){let{slug:t,componentDir:n,name:r,revisionQuery:o,force:s}=e;if(!s&&I.existsSync(n)){let f=oe(n);if(Gt(n,f))return{name:r,status:"skipped",message:"local has uncommitted changes; pass --force to overwrite"}}let i=`${x(t)}/api/apps/components/${encodeURIComponent(r)}`,a;try{a=await d(`${i}${o}`)}catch(f){if(o===""&&Tr(f))try{a=await d(`${i}?revision=draft`)}catch(j){return{name:r,status:"failed",message:j instanceof Error?j.message:String(j)}}else return{name:r,status:"failed",message:f instanceof Error?f.message:String(f)}}I.mkdirSync(n,{recursive:!0});let l=JSON.stringify(a.manifest,null,2)+`
100
+ `;I.writeFileSync(X.join(n,"manifest.json"),l),I.writeFileSync(X.join(n,"bundle.js"),a.bundle);let c=["manifest.json","bundle.js"],p="";a.source!==null&&(I.writeFileSync(X.join(n,"component.tsx"),a.source),c.push("component.tsx"),p=V(a.source)),z(n,{version:a.version,manifestHash:V(l),sourceHash:p,bundleHash:V(a.bundle)});let u=re(n);return z(n,{version:a.version,manifestHash:u.manifestHash,sourceHash:u.sourceHash??"",bundleHash:u.bundleHash??""}),{name:r,status:"pulled",version:a.version,wrote:c}}function Kt(e){I.mkdirSync(X.join(e,"components"),{recursive:!0})}function Tr(e){return e instanceof D&&e.status===404}function Wt(e){let t=h(e.flags,"version");return t?`?version=${encodeURIComponent(t)}`:m(e.flags,"draft")?"?revision=draft":m(e.flags,"live")?"?revision=live":""}function zt(e,t){switch(e.status){case"pulled":{let n=e.wrote?`{${e.wrote.join(", ")}}`:"";process.stdout.write(` pulled ${e.name} v${e.version} ${n}
101
101
  `);return}case"skipped":process.stdout.write(` skipped ${e.name}: ${e.message}
102
102
  `);return;case"failed":process.stdout.write(` failed ${e.name}: ${e.message??"unknown error"}
103
- `);return}}import*as v from"fs";import*as $ from"path";async function Yt(e){let t=E(),n=process.cwd();_r(n);let r=$.join(n,"components");if(!v.existsSync(r))throw new Error("No components/ directory here. Run `gs apps init <name>` to scaffold the project root and your first component.");let o=e.positional,s=h(e.flags,"manifest"),i=h(e.flags,"bundle");if(o.length!==1&&(s||i))throw new Error("--manifest / --bundle can only be used together with a single `gs apps push <name>`.");if(o.length>0){let c=m(e.flags,"force")||s!==void 0||i!==void 0,p=[];for(let u of o){let f=await zt({slug:t,root:n,name:u,...s!==void 0?{manifestPath:s}:{},...i!==void 0?{bundlePath:i}:{},force:c});p.push(f),Xt(f)}p.length>1&&Jt(p,t),p.some(u=>u.status==="failed")&&(process.exitCode=1);return}let a=Rr(r);if(a.length===0){process.stdout.write("(no components in ./components \u2014 run `gs apps init <name>` to add one)\n");return}let l=[];for(let c of a){let p=await zt({slug:t,root:n,name:c,force:!1});l.push(p),Xt(p)}Jt(l,t),l.some(c=>c.status==="failed")&&(process.exitCode=1)}function Jt(e,t){let n=e.filter(i=>i.status==="pushed").length,r=e.filter(i=>i.status==="unchanged").length,o=e.filter(i=>i.status==="failed").length,s=[`${n} pushed`,`${r} unchanged`];o>0&&s.push(`${o} failed`),process.stdout.write(`
103
+ `);return}}import*as v from"fs";import*as E from"path";async function Zt(e){let t=$(),n=process.cwd();Or(n);let r=E.join(n,"components");if(!v.existsSync(r))throw new Error("No components/ directory here. Run `gs apps init <name>` to scaffold the project root and your first component.");let o=e.positional,s=h(e.flags,"manifest"),i=h(e.flags,"bundle");if(o.length!==1&&(s||i))throw new Error("--manifest / --bundle can only be used together with a single `gs apps push <name>`.");if(o.length>0){let c=m(e.flags,"force")||s!==void 0||i!==void 0,p=[];for(let u of o){let f=await Yt({slug:t,root:n,name:u,...s!==void 0?{manifestPath:s}:{},...i!==void 0?{bundlePath:i}:{},force:c});p.push(f),Qt(f)}p.length>1&&Xt(p,t),p.some(u=>u.status==="failed")&&(process.exitCode=1);return}let a=Lr(r);if(a.length===0){process.stdout.write("(no components in ./components \u2014 run `gs apps init <name>` to add one)\n");return}let l=[];for(let c of a){let p=await Yt({slug:t,root:n,name:c,force:!1});l.push(p),Qt(p)}Xt(l,t),l.some(c=>c.status==="failed")&&(process.exitCode=1)}function Xt(e,t){let n=e.filter(i=>i.status==="pushed").length,r=e.filter(i=>i.status==="unchanged").length,o=e.filter(i=>i.status==="failed").length,s=[`${n} pushed`,`${r} unchanged`];o>0&&s.push(`${o} failed`),process.stdout.write(`
104
104
  ${s.join(", ")} (of ${e.length}) \u2192 ${t}
105
- `)}async function zt(e){let{slug:t,root:n,name:r,force:o}=e,s=$.join(n,"components",r);if(!v.existsSync(s))return{name:r,status:"failed",message:`components/${r}/ does not exist`};let i=e.manifestPath?$.resolve(e.manifestPath):$.join(s,"manifest.json"),a=e.bundlePath?$.resolve(e.bundlePath):$.join(s,"bundle.js"),l=$.join(s,"component.tsx");if(!v.existsSync(a))return{name:r,status:"failed",message:`bundle not found: ${a} (did you run \`npm run build\`?)`};let c=xe({root:n,name:r,manifestPath:i,sourcePath:l});for(let T of Oe(c.diagnostics))process.stdout.write(` ${ce(T)}
106
- `);if(!c.ok)return{name:r,status:"failed",message:ae(c.diagnostics).map(T=>`${T.file}: ${T.message}`).join(`
107
- ${Qt}`)};let p=v.readFileSync(i,"utf8"),u=ee(s),f=ke(s),j=e.bundlePath===void 0&&f?.bundleHash!==void 0&&f.sourceHash!==(u.sourceHash??"")&&f.bundleHash===(u.bundleHash??"");if(!o&&f!==null&&f.manifestHash===u.manifestHash&&f.sourceHash===(u.sourceHash??"")&&f.bundleHash!==void 0&&f.bundleHash===(u.bundleHash??""))return{name:r,status:"unchanged"};let k=v.readFileSync(a,"utf8"),J=v.existsSync(l)?v.readFileSync(l,"utf8"):null,R=new FormData;R.append("manifest",new Blob([p],{type:"application/json"}),"manifest.json"),R.append("bundle",new Blob([k],{type:"text/javascript"}),"bundle.js"),J!==null&&R.append("source",new Blob([J],{type:"text/plain; charset=utf-8"}),"component.tsx"),o||R.append("base_version",String(f?.version??0));let xn=`${C(t)}/api/apps/components/${encodeURIComponent(r)}`,pe;try{pe=await d(xn,{method:"POST",multipart:R})}catch(T){return{name:r,status:"failed",message:T instanceof Error?T.message:String(T)}}let Ae=ee(s);return ue(s,{version:pe.version,manifestHash:Ae.manifestHash,sourceHash:Ae.sourceHash??"",bundleHash:Ae.bundleHash??""}),{name:r,status:"pushed",version:pe.version,permalink:pe.permalink,...j?{staleBundle:!0}:{}}}function Rr(e){return v.readdirSync(e).filter(t=>{let n=$.join(e,t);return v.statSync(n).isDirectory()&&v.existsSync($.join(n,"manifest.json"))}).sort()}function _r(e){let t=$.join(e,"manifest.json"),n=$.join(e,"components");if(v.existsSync(t)&&!v.existsSync(n))throw new Error(["Detected the old single-component layout (manifest.json at the project root).","The CLI now uses a multi-component layout: scaffold a fresh dir with","`gs apps init`, then move your component into `components/<name>/`. Re-run `gs apps push`","from the new project root."].join(" "))}var Qt=" ".repeat(12);function Xt(e){switch(e.status){case"pushed":process.stdout.write(` pushed ${e.name} v${e.version} \u2192 ${e.permalink??""}
108
- `),e.staleBundle&&process.stdout.write(`${Qt}component.tsx changed but bundle.js did not \u2014 did you forget to build? Run \`gs build ${e.name}\` and push again.
105
+ `)}async function Yt(e){let{slug:t,root:n,name:r,force:o}=e,s=E.join(n,"components",r);if(!v.existsSync(s))return{name:r,status:"failed",message:`components/${r}/ does not exist`};let i=e.manifestPath?E.resolve(e.manifestPath):E.join(s,"manifest.json"),a=e.bundlePath?E.resolve(e.bundlePath):E.join(s,"bundle.js"),l=E.join(s,"component.tsx");if(!v.existsSync(a))return{name:r,status:"failed",message:`bundle not found: ${a} (did you run \`npm run build\`?)`};let c=Pe({root:n,name:r,manifestPath:i,sourcePath:l});for(let L of Fe(c.diagnostics))process.stdout.write(` ${fe(L)}
106
+ `);if(!c.ok)return{name:r,status:"failed",message:pe(c.diagnostics).map(L=>`${L.file}: ${L.message}`).join(`
107
+ ${en}`)};let p=v.readFileSync(i,"utf8"),u=re(s),f=oe(s),j=e.bundlePath===void 0&&f?.bundleHash!==void 0&&f.sourceHash!==(u.sourceHash??"")&&f.bundleHash===(u.bundleHash??"");if(!o&&f!==null&&f.manifestHash===u.manifestHash&&f.sourceHash===(u.sourceHash??"")&&f.bundleHash!==void 0&&f.bundleHash===(u.bundleHash??""))return{name:r,status:"unchanged"};let P=v.readFileSync(a,"utf8"),Y=v.existsSync(l)?v.readFileSync(l,"utf8"):null,R=new FormData;R.append("manifest",new Blob([p],{type:"application/json"}),"manifest.json"),R.append("bundle",new Blob([P],{type:"text/javascript"}),"bundle.js"),Y!==null&&R.append("source",new Blob([Y],{type:"text/plain; charset=utf-8"}),"component.tsx"),o||R.append("base_version",String(f?.version??0));let $n=`${x(t)}/api/apps/components/${encodeURIComponent(r)}`,de;try{de=await d($n,{method:"POST",multipart:R})}catch(L){return{name:r,status:"failed",message:L instanceof Error?L.message:String(L)}}let Re=re(s);return z(s,{version:de.version,manifestHash:Re.manifestHash,sourceHash:Re.sourceHash??"",bundleHash:Re.bundleHash??""}),{name:r,status:"pushed",version:de.version,permalink:de.permalink,...j?{staleBundle:!0}:{}}}function Lr(e){return v.readdirSync(e).filter(t=>{let n=E.join(e,t);return v.statSync(n).isDirectory()&&v.existsSync(E.join(n,"manifest.json"))}).sort()}function Or(e){let t=E.join(e,"manifest.json"),n=E.join(e,"components");if(v.existsSync(t)&&!v.existsSync(n))throw new Error(["Detected the old single-component layout (manifest.json at the project root).","The CLI now uses a multi-component layout: scaffold a fresh dir with","`gs apps init`, then move your component into `components/<name>/`. Re-run `gs apps push`","from the new project root."].join(" "))}var en=" ".repeat(12);function Qt(e){switch(e.status){case"pushed":process.stdout.write(` pushed ${e.name} v${e.version} \u2192 ${e.permalink??""}
108
+ `),e.staleBundle&&process.stdout.write(`${en}component.tsx changed but bundle.js did not \u2014 did you forget to build? Run \`gs build ${e.name}\` and push again.
109
109
  `);return;case"unchanged":process.stdout.write(` unchanged ${e.name}
110
110
  `);return;case"failed":process.stdout.write(` failed ${e.name}: ${e.message??"unknown error"}
111
- `);return}}async function en(e){let t=e.positional;if(t.length===0)throw new Error("Usage: gs apps publish <name> [<name>...] [--version N]");let n=E(),r=h(e.flags,"version"),o;if(r!==void 0){if(t.length>1)throw new Error("--version is per-component; pass it together with a single `gs apps publish <name>`.");let c=Number.parseInt(r,10);if(!Number.isInteger(c)||c<1)throw new Error(`Invalid --version: ${r}`);o=c}if(t.length===1){let c=t[0],p=await Zt(n,c,o);process.stdout.write(`Published ${c} (v${p.live_version}). ${p.permalink}
112
- `);return}let s=[];for(let c of t){let p;try{let u=await Zt(n,c,o);p={name:c,status:"published",version:u.live_version,permalink:u.permalink}}catch(u){p={name:c,status:"failed",message:u instanceof Error?u.message:String(u)}}s.push(p),Tr(p)}let i=s.filter(c=>c.status==="published").length,a=s.filter(c=>c.status==="failed").length,l=[`${i} published`];a>0&&l.push(`${a} failed`),process.stdout.write(`
111
+ `);return}}async function nn(e){let t=e.positional;if(t.length===0)throw new Error("Usage: gs apps publish <name> [<name>...] [--version N]");let n=$(),r=h(e.flags,"version"),o;if(r!==void 0){if(t.length>1)throw new Error("--version is per-component; pass it together with a single `gs apps publish <name>`.");let c=Number.parseInt(r,10);if(!Number.isInteger(c)||c<1)throw new Error(`Invalid --version: ${r}`);o=c}if(t.length===1){let c=t[0],p=await tn(n,c,o);process.stdout.write(`Published ${c} (v${p.live_version}). ${p.permalink}
112
+ `);return}let s=[];for(let c of t){let p;try{let u=await tn(n,c,o);p={name:c,status:"published",version:u.live_version,permalink:u.permalink}}catch(u){p={name:c,status:"failed",message:u instanceof Error?u.message:String(u)}}s.push(p),Ir(p)}let i=s.filter(c=>c.status==="published").length,a=s.filter(c=>c.status==="failed").length,l=[`${i} published`];a>0&&l.push(`${a} failed`),process.stdout.write(`
113
113
  ${l.join(", ")} (of ${s.length}) \u2192 ${n}
114
- `),a>0&&(process.exitCode=1)}async function Zt(e,t,n){let r=`${C(e)}/api/apps/components/${encodeURIComponent(t)}/publish`;return d(r,{method:"POST",body:n!==void 0?{version:n}:{}})}function Tr(e){if(e.status==="published"){process.stdout.write(` published ${e.name} v${e.version} \u2192 ${e.permalink??""}
114
+ `),a>0&&(process.exitCode=1)}async function tn(e,t,n){let r=`${x(e)}/api/apps/components/${encodeURIComponent(t)}/publish`;return d(r,{method:"POST",body:n!==void 0?{version:n}:{}})}function Ir(e){if(e.status==="published"){process.stdout.write(` published ${e.name} v${e.version} \u2192 ${e.permalink??""}
115
115
  `);return}process.stdout.write(` failed ${e.name}: ${e.message??"unknown error"}
116
- `)}async function tn(e){let t=e.positional[0];if(!t)throw new Error("Usage: gs apps unpublish <name>");let n=E(),r=`${C(n)}/api/apps/components/${encodeURIComponent(t)}/unpublish`;await d(r,{method:"POST",body:{}}),process.stdout.write(`Unpublished ${t}.
117
- `)}import*as nn from"readline";async function rn(e){let t=e.positional[0];if(!t)throw new Error("Usage: gs apps delete <name> [--yes]");let n=E();if(!m(e.flags,"yes")&&(await Lr(`Soft-delete component "${t}" in store "${n}"? Type "yes" to confirm: `)).trim()!=="yes"){process.stdout.write(`Aborted.
118
- `);return}let r=`${C(n)}/api/apps/components/${encodeURIComponent(t)}`;await d(r,{method:"DELETE"}),process.stdout.write(`Deleted ${t}.
119
- `)}function Lr(e){return new Promise(t=>{let n=nn.createInterface({input:process.stdin,output:process.stdout});n.question(e,r=>{n.close(),t(r)})})}var on=`gs apps \u2014 author and ship custom in-chat apps
116
+ `)}async function rn(e){let t=e.positional[0];if(!t)throw new Error("Usage: gs apps unpublish <name>");let n=$(),r=`${x(n)}/api/apps/components/${encodeURIComponent(t)}/unpublish`;await d(r,{method:"POST",body:{}}),process.stdout.write(`Unpublished ${t}.
117
+ `)}import*as on from"readline";async function sn(e){let t=e.positional[0];if(!t)throw new Error("Usage: gs apps delete <name> [--yes]");let n=$();if(!m(e.flags,"yes")&&(await Fr(`Soft-delete component "${t}" in store "${n}"? Type "yes" to confirm: `)).trim()!=="yes"){process.stdout.write(`Aborted.
118
+ `);return}let r=`${x(n)}/api/apps/components/${encodeURIComponent(t)}`;await d(r,{method:"DELETE"}),process.stdout.write(`Deleted ${t}.
119
+ `)}function Fr(e){return new Promise(t=>{let n=on.createInterface({input:process.stdin,output:process.stdout});n.question(e,r=>{n.close(),t(r)})})}import*as T from"fs";import*as $e from"path";var Nr=/^[a-z][a-z0-9_]*$/;async function an(e){let[t,n]=e.positional;if(!t||!n||e.positional.length>2)throw new Error("Usage: gs apps rename <old-name> <new-name>");if(!Nr.test(n))throw new Error(`Invalid name "${n}": use lowercase letters, digits and underscores, starting with a letter.`);if(t===n)throw new Error(`"${t}" already has that name.`);let r=$(),o=$e.join(process.cwd(),"components",t),s=$e.join(process.cwd(),"components",n),i=T.existsSync(o);if(T.existsSync(s))throw new Error(`components/${n}/ already exists; move it aside first.`);let a=`${x(r)}/api/apps/components/${encodeURIComponent(t)}/rename`;if(await d(a,{method:"POST",body:{name:n}}),!i){process.stdout.write(`Renamed ${t} \u2192 ${n}.
120
+ `);return}T.renameSync(o,s),Dr(s,n),process.stdout.write(`Renamed ${t} \u2192 ${n}, including components/${n}/.
121
+ `)}function Dr(e,t){let n=$e.join(e,"manifest.json");if(!T.existsSync(n))return;let r=T.readFileSync(n,"utf8"),o=JSON.stringify({...JSON.parse(r),name:t},null,2)+`
122
+ `;T.writeFileSync(n,o);let s=oe(e);s&&s.manifestHash===V(r)&&z(e,{...s,manifestHash:V(o)})}var cn=`gs apps \u2014 author and ship custom in-chat apps
120
123
 
121
124
  Usage:
122
125
  gs apps <subcommand> [args] [flags]
@@ -129,39 +132,47 @@ Subcommands:
129
132
  push [<name>...] Upload changed components from \`components/\`.
130
133
  publish <name>... Promote the draft(s) (or --version N) to live.
131
134
  unpublish <name> Clear the live pointer.
135
+ rename <old> <new> Rename a component, keeping its versions and live state.
132
136
  delete <name> Soft-delete the component.
133
- `;async function Fe(e){let t=e.positional[0],n={...e,positional:e.positional.slice(1)};switch(t){case void 0:case"help":return process.stdout.write(on),0;case"init":return gt(n),0;case"build":return await Nt(n),0;case"list":return await Dt(n),0;case"pull":return await Ut(n),0;case"push":return await Yt(n),0;case"publish":return await en(n),0;case"unpublish":return await tn(n),0;case"delete":return await rn(n),0;default:return process.stderr.write(`Unknown apps subcommand: ${t}
137
+ `;async function De(e){let t=e.positional[0],n={...e,positional:e.positional.slice(1)};switch(t){case void 0:case"help":return process.stdout.write(cn),0;case"init":return yt(n),0;case"build":return await Bt(n),0;case"list":return await Ht(n),0;case"pull":return await qt(n),0;case"push":return await Zt(n),0;case"publish":return await nn(n),0;case"unpublish":return await rn(n),0;case"rename":return await an(n),0;case"delete":return await sn(n),0;default:return process.stderr.write(`Unknown apps subcommand: ${t}
134
138
 
135
- ${on}`),1}}async function sn(e){let t=y(e),n=`${b(t)}/configure/config`,r=await d(n);if(m(e.flags,"json")){process.stdout.write(JSON.stringify(r.brand,null,2)+`
136
- `);return}Or(t,r.brand)}function Or(e,t){let n=[`Configuration for ${e}:`,""];n.push(` displayName ${t.displayName??"\u2014"}`),n.push(` assistantName ${t.assistantName??"\u2014"}`),n.push(` storeLink ${t.storeLink??"\u2014"}`),n.push(` extraOrigins ${Ne(t.extraOrigins)}`),n.push(` icon ${t.icon?.url??"\u2014"}`),n.push(` logoLight ${t.logo?.light?.url??"\u2014"}`),n.push(` logoDark ${t.logo?.dark?.url??"\u2014"}`),n.push(` theme ${t.theme?JSON.stringify(t.theme):"\u2014"}`),n.push(` cspScriptHosts ${Ne(t.cspScriptHosts)}`),n.push(` cspConnectHosts ${Ne(t.cspConnectHosts)}`),process.stdout.write(n.join(`
139
+ ${cn}`),1}}async function ln(e){let t=y(e),n=`${S(t)}/configure/config`,r=await d(n);if(m(e.flags,"json")){process.stdout.write(JSON.stringify(r.brand,null,2)+`
140
+ `);return}Br(t,r.brand)}function Br(e,t){let n=[`Configuration for ${e}:`,""];n.push(` displayName ${t.displayName??"\u2014"}`),n.push(` assistantName ${t.assistantName??"\u2014"}`),n.push(` storeLink ${t.storeLink??"\u2014"}`),n.push(` extraOrigins ${Be(t.extraOrigins)}`),n.push(` icon ${t.icon?.url??"\u2014"}`),n.push(` logoLight ${t.logo?.light?.url??"\u2014"}`),n.push(` logoDark ${t.logo?.dark?.url??"\u2014"}`),n.push(` theme ${t.theme?JSON.stringify(t.theme):"\u2014"}`),n.push(` cspScriptHosts ${Be(t.cspScriptHosts)}`),n.push(` cspConnectHosts ${Be(t.cspConnectHosts)}`),process.stdout.write(n.join(`
137
141
  `)+`
138
- `)}function Ne(e){return!e||e.length===0?"\u2014":e.join(", ")}import*as Pe from"fs";import*as ln from"path";var an="theme.",Ir=["displayName","assistantName","storeLink"],Fr=["extraOrigins","cspScriptHosts","cspConnectHosts"];async function un(e){let t=y(e),n={};for(let c of Ir){if(!(c in e.flags))continue;let p=e.flags[c];if(typeof p!="string")throw new Error(`--${c} requires a value (use --${c} "" to clear).`);n[c]=p===""?null:p}for(let c of Fr){if(!(c in e.flags))continue;let p=e.flags[c];if(typeof p!="string")throw new Error(`--${c} requires a comma-separated value (use --${c} "" to clear).`);let u=p.split(",").map(f=>f.trim()).filter(f=>f.length>0);n[c]=u.length===0?null:u}let r=h(e.flags,"themeFile"),o=Br(e.flags),s=m(e.flags,"replace");if("theme"in e.flags&&r!==void 0)throw new Error("Pass either --theme or --themeFile, not both.");if(o!==null&&("theme"in e.flags||r!==void 0))throw new Error("Pass either --theme.<field> flags or a whole --theme/--themeFile object, not both.");let i;if("theme"in e.flags){let c=e.flags.theme;if(typeof c!="string")throw new Error('--theme requires a JSON value (use --theme "" to clear).');i=c===""?null:cn(c,"--theme")}else r!==void 0?i=cn(Nr(r,"--themeFile"),"--themeFile"):o!==null&&(i=o);if(i!==void 0&&(n.theme=i===null||s?i:{...await Dr(t),...i},n.theme!==null)){let c=n.theme;for(let[p,u]of Object.entries(c))u===""&&delete c[p]}if(Object.keys(n).length===0)throw new Error('Nothing to save. Pass at least one field flag, e.g. `gs configure set --displayName "Acme"`.');let a=`${b(t)}/configure/save`,l=await d(a,{method:"POST",body:n,validationDetail:!0});if(m(e.flags,"json")){process.stdout.write(JSON.stringify(l.config,null,2)+`
142
+ `)}function Be(e){return!e||e.length===0?"\u2014":e.join(", ")}import*as Ce from"fs";import*as fn from"path";var un="theme.",Hr=["displayName","assistantName","storeLink"],Mr=["extraOrigins","cspScriptHosts","cspConnectHosts"];async function dn(e){let t=y(e),n={};for(let c of Hr){if(!(c in e.flags))continue;let p=e.flags[c];if(typeof p!="string")throw new Error(`--${c} requires a value (use --${c} "" to clear).`);n[c]=p===""?null:p}for(let c of Mr){if(!(c in e.flags))continue;let p=e.flags[c];if(typeof p!="string")throw new Error(`--${c} requires a comma-separated value (use --${c} "" to clear).`);let u=p.split(",").map(f=>f.trim()).filter(f=>f.length>0);n[c]=u.length===0?null:u}let r=h(e.flags,"themeFile"),o=qr(e.flags),s=m(e.flags,"replace");if("theme"in e.flags&&r!==void 0)throw new Error("Pass either --theme or --themeFile, not both.");if(o!==null&&("theme"in e.flags||r!==void 0))throw new Error("Pass either --theme.<field> flags or a whole --theme/--themeFile object, not both.");let i;if("theme"in e.flags){let c=e.flags.theme;if(typeof c!="string")throw new Error('--theme requires a JSON value (use --theme "" to clear).');i=c===""?null:pn(c,"--theme")}else r!==void 0?i=pn(Ur(r,"--themeFile"),"--themeFile"):o!==null&&(i=o);if(i!==void 0&&(n.theme=i===null||s?i:{...await Gr(t),...i},n.theme!==null)){let c=n.theme;for(let[p,u]of Object.entries(c))u===""&&delete c[p]}if(Object.keys(n).length===0)throw new Error('Nothing to save. Pass at least one field flag, e.g. `gs configure set --displayName "Acme"`.');let a=`${S(t)}/configure/save`,l=await d(a,{method:"POST",body:n,validationDetail:!0});if(m(e.flags,"json")){process.stdout.write(JSON.stringify(l.config,null,2)+`
139
143
  `);return}process.stdout.write(`Saved ${Object.keys(n).join(", ")} \u2192 ${t}
140
- `)}function Nr(e,t){let n=ln.resolve(e);if(!Pe.existsSync(n))throw new Error(`${t}: file not found: ${n}`);return Pe.readFileSync(n,"utf8")}function cn(e,t){let n;try{n=JSON.parse(e)}catch(r){throw new Error(`${t}: not valid JSON: ${r.message}`)}if(typeof n!="object"||n===null||Array.isArray(n))throw new Error(`${t}: theme must be a JSON object.`);return n}async function Dr(e){let t=`${b(e)}/configure/config`;return(await d(t)).brand.theme??{}}function Br(e){let t={};for(let[n,r]of Object.entries(e)){if(!n.startsWith(an))continue;let o=n.slice(an.length),s=H[o];if(!s){let i=ct(o);throw new Error(`Unknown theme field "${o}".
141
- Valid fields: ${Object.keys(H).join(", ")}.`+(i.length>0?`
142
- Did you mean: ${i.join(", ")}?`:""))}if(typeof r!="string"){if(s.kind==="boolean"){t[o]=!0;continue}throw new Error(`--${n} requires a value (use --${n} "" to clear).`)}t[o]=Hr(n,o,r)}return Object.keys(t).length>0?t:null}function Hr(e,t,n){let r=H[t];if(!r||n==="")return n;if(r.values&&!r.values.includes(n))throw new Error(`--${e} must be one of: ${r.values.join(", ")} (got "${n}").`);if(r.kind==="boolean"){if(n!=="true"&&n!=="false")throw new Error(`--${e} must be true or false (got "${n}").`);return n==="true"}if(r.kind==="integer"){let o=Number.parseInt(n,10);if(!Number.isInteger(o)||String(o)!==n.trim())throw new Error(`--${e} must be an integer (got "${n}").`);return o}return n}import*as Ee from"fs";import*as te from"path";var Ce=["icon","logoLight","logoDark"];function $e(e){if(e&&Ce.includes(e))return e;throw new Error(`Asset kind must be one of: ${Ce.join(", ")}.`)}var Mr={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".webp":"image/webp"};async function pn(e){let t=y(e),n=$e(e.positional[0]),r=e.positional[1];if(!r)throw new Error(`Usage: gs configure upload <${Ce.join("|")}> <file>`);let o=te.resolve(r);if(!Ee.existsSync(o))throw new Error(`File not found: ${o}`);let s=Mr[te.extname(o).toLowerCase()];if(!s)throw new Error("Unsupported image type. Use .png, .jpg, or .webp.");let i=Ee.readFileSync(o),a=new FormData;a.append("file",new Blob([new Uint8Array(i)],{type:s}),te.basename(o));let l=`${b(t)}/configure/upload/${n}`,c=await d(l,{method:"POST",multipart:a});process.stdout.write(`Uploaded ${n} \u2192 ${c.url}
143
- `)}async function fn(e){let t=y(e),n=$e(e.positional[0]),r=`${b(t)}/configure/delete/${n}`;await d(r,{method:"POST",body:{}}),process.stdout.write(`Cleared ${n} for ${t}
144
- `)}async function dn(e){let t=e.positional[0]??"show",n={...e,positional:e.positional.slice(1)};switch(t){case"show":await sn(n);return;case"set":await un(n);return;case"upload":await pn(n);return;case"clear":await fn(n);return;default:throw new Error(`Unknown configure subcommand: ${t}. Use \`gs configure [set|upload|clear]\`.`)}}async function A(e){let t=`${b(e)}/connectors/config`;return d(t)}function I(e){return{id:e.id,name:e.name,url:e.url,transport:e.transport,authKind:e.authKind,enabled:e.enabled,profileUrl:e.profileUrl}}async function q(e,t,n,r=t.makerEnabled){let o=`${b(e)}/connectors/save`;return d(o,{method:"POST",body:{makerEnabled:r,makerPriority:Math.min(t.makerPriority,n.length),connectors:n}})}function ne(e,t){let n=e.connectors.find(o=>o.id===t);if(n)return n;let r=e.connectors.filter(o=>o.name===t);if(r.length===1)return r[0];if(r.length>1){let o=r.map(s=>s.id).join(", ");throw new Error(`Multiple connectors are named "${t}". Use an id instead: ${o}`)}throw new Error(`No connector named "${t}". Run \`gs connectors\` to see them.`)}async function mn(e){let t=y(e),n=await A(t);if(m(e.flags,"json")){process.stdout.write(JSON.stringify(n,null,2)+`
144
+ `)}function Ur(e,t){let n=fn.resolve(e);if(!Ce.existsSync(n))throw new Error(`${t}: file not found: ${n}`);return Ce.readFileSync(n,"utf8")}function pn(e,t){let n;try{n=JSON.parse(e)}catch(r){throw new Error(`${t}: not valid JSON: ${r.message}`)}if(typeof n!="object"||n===null||Array.isArray(n))throw new Error(`${t}: theme must be a JSON object.`);return n}async function Gr(e){let t=`${S(e)}/configure/config`;return(await d(t)).brand.theme??{}}function qr(e){let t={};for(let[n,r]of Object.entries(e)){if(!n.startsWith(un))continue;let o=n.slice(un.length),s=M[o];if(!s){let i=ut(o);throw new Error(`Unknown theme field "${o}".
145
+ Valid fields: ${Object.keys(M).join(", ")}.`+(i.length>0?`
146
+ Did you mean: ${i.join(", ")}?`:""))}if(typeof r!="string"){if(s.kind==="boolean"){t[o]=!0;continue}throw new Error(`--${n} requires a value (use --${n} "" to clear).`)}t[o]=Vr(n,o,r)}return Object.keys(t).length>0?t:null}function Vr(e,t,n){let r=M[t];if(!r||n==="")return n;if(r.values&&!r.values.includes(n))throw new Error(`--${e} must be one of: ${r.values.join(", ")} (got "${n}").`);if(r.kind==="boolean"){if(n!=="true"&&n!=="false")throw new Error(`--${e} must be true or false (got "${n}").`);return n==="true"}if(r.kind==="integer"){let o=Number.parseInt(n,10);if(!Number.isInteger(o)||String(o)!==n.trim())throw new Error(`--${e} must be an integer (got "${n}").`);return o}return n}import*as je from"fs";import*as se from"path";var Ee=["icon","logoLight","logoDark"];function Ae(e){if(e&&Ee.includes(e))return e;throw new Error(`Asset kind must be one of: ${Ee.join(", ")}.`)}var Jr={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".webp":"image/webp"};async function mn(e){let t=y(e),n=Ae(e.positional[0]),r=e.positional[1];if(!r)throw new Error(`Usage: gs configure upload <${Ee.join("|")}> <file>`);let o=se.resolve(r);if(!je.existsSync(o))throw new Error(`File not found: ${o}`);let s=Jr[se.extname(o).toLowerCase()];if(!s)throw new Error("Unsupported image type. Use .png, .jpg, or .webp.");let i=je.readFileSync(o),a=new FormData;a.append("file",new Blob([new Uint8Array(i)],{type:s}),se.basename(o));let l=`${S(t)}/configure/upload/${n}`,c=await d(l,{method:"POST",multipart:a});process.stdout.write(`Uploaded ${n} \u2192 ${c.url}
147
+ `)}async function gn(e){let t=y(e),n=Ae(e.positional[0]),r=`${S(t)}/configure/delete/${n}`;await d(r,{method:"POST",body:{}}),process.stdout.write(`Cleared ${n} for ${t}
148
+ `)}async function hn(e){let t=e.positional[0]??"show",n={...e,positional:e.positional.slice(1)};switch(t){case"show":await ln(n);return;case"set":await dn(n);return;case"upload":await mn(n);return;case"clear":await gn(n);return;default:throw new Error(`Unknown configure subcommand: ${t}. Use \`gs configure [set|upload|clear]\`.`)}}async function A(e){let t=`${S(e)}/connectors/config`;return d(t)}function F(e){return{id:e.id,name:e.name,url:e.url,transport:e.transport,authKind:e.authKind,enabled:e.enabled,profileUrl:e.profileUrl}}async function J(e,t,n,r=t.makerEnabled){let o=`${S(e)}/connectors/save`;return d(o,{method:"POST",body:{makerEnabled:r,makerPriority:Math.min(t.makerPriority,n.length),connectors:n}})}function ie(e,t){let n=e.connectors.find(o=>o.id===t);if(n)return n;let r=e.connectors.filter(o=>o.name===t);if(r.length===1)return r[0];if(r.length>1){let o=r.map(s=>s.id).join(", ");throw new Error(`Multiple connectors are named "${t}". Use an id instead: ${o}`)}throw new Error(`No connector named "${t}". Run \`gs connectors\` to see them.`)}async function yn(e){let t=y(e),n=await A(t);if(m(e.flags,"json")){process.stdout.write(JSON.stringify(n,null,2)+`
145
149
  `);return}if(process.stdout.write(`Maker MCP: ${n.makerEnabled?"on":"off"} (position ${n.makerPriority+1})
146
150
  `),n.connectors.length===0){process.stdout.write(`(no custom connectors in ${t})
147
- `);return}let r=n.connectors.map(s=>({name:s.name,enabled:s.enabled?"on":"off",auth:s.authKind==="bearer"?s.hasToken?"bearer":"bearer (no token)":"none",url:s.url})),o={name:Math.max(4,...r.map(s=>s.name.length)),enabled:Math.max(7,...r.map(s=>s.enabled.length)),auth:Math.max(4,...r.map(s=>s.auth.length))};process.stdout.write(`${re("NAME",o.name)} ${re("ENABLED",o.enabled)} ${re("AUTH",o.auth)} URL
148
- `);for(let s of r)process.stdout.write(`${re(s.name,o.name)} ${re(s.enabled,o.enabled)} ${re(s.auth,o.auth)} ${s.url}
149
- `)}function re(e,t){return e.length>=t?e:e+" ".repeat(t-e.length)}async function gn(e){let t=y(e),n=e.positional[0];if(!n)throw new Error("Usage: gs connectors add <name> --url <url> [--token <token>]");let r=h(e.flags,"url");if(!r)throw new Error("--url is required for `gs connectors add`.");let o=h(e.flags,"token"),s=h(e.flags,"profileUrl")??null,i=!m(e.flags,"disabled");if(!m(e.flags,"force")){let u=`${b(t)}/connectors/probe`,f=await d(u,{method:"POST",body:{url:r,...o!==void 0?{token:o}:{},...s!==null?{profileUrl:s}:{}}});if(!f.ok)throw new Error(`Connector did not answer tool discovery${f.error?`: ${f.error}`:""}. Fix the URL/token or pass --force to save it anyway.`);process.stdout.write(`Probe ok \u2014 ${f.toolCount??0} tool(s) discovered.
150
- `)}let a=await A(t),l={id:"",name:n,url:r,transport:"http",authKind:o?"bearer":"none",enabled:i,profileUrl:s,...o!==void 0?{token:o}:{}},p=(await q(t,a,[...a.connectors.map(I),l])).connectors.find(u=>u.name===n);process.stdout.write(`Added connector "${n}"${p?` (${p.id})`:""} \u2192 ${t}
151
- `)}async function hn(e){let t=y(e),n=e.positional[0];if(!n)throw new Error("Usage: gs connectors remove <name|id>");let r=await A(t),o=ne(r,n),s=r.connectors.filter(i=>i.id!==o.id).map(I);await q(t,r,s),process.stdout.write(`Removed connector "${o.name}" from ${t}
152
- `)}async function De(e,t){let n=y(e),r=e.positional[0];if(!r)throw new Error(`Usage: gs connectors ${t?"enable":"disable"} <name|id>`);let o=await A(n),s=ne(o,r),i=o.connectors.map(a=>a.id===s.id?{...I(a),enabled:t}:I(a));await q(n,o,i),process.stdout.write(`Connector "${s.name}" is now ${t?"enabled":"disabled"}
153
- `)}async function yn(e){let t=y(e),n=e.positional[0];if(n!=="on"&&n!=="off")throw new Error("Usage: gs connectors maker on|off");let r=await A(t);await q(t,r,r.connectors.map(I),n==="on"),process.stdout.write(`Maker MCP is now ${n}
154
- `)}async function wn(e){let t=y(e),n=await A(t),r=null,o=e.positional[0];if(o&&(r=ne(n,o).id),n.connectors.length===0){process.stdout.write(`(no custom connectors in ${t})
155
- `);return}let s=`${b(t)}/connectors/health`,i=await d(s,{method:"POST",body:r?{id:r}:{}});if(m(e.flags,"json")){process.stdout.write(JSON.stringify(i.health,null,2)+`
151
+ `);return}let r=n.connectors.map(s=>({name:s.name,enabled:s.enabled?"on":"off",auth:s.authKind==="bearer"?s.hasToken?"bearer":"bearer (no token)":"none",url:s.url})),o={name:Math.max(4,...r.map(s=>s.name.length)),enabled:Math.max(7,...r.map(s=>s.enabled.length)),auth:Math.max(4,...r.map(s=>s.auth.length))};process.stdout.write(`${ae("NAME",o.name)} ${ae("ENABLED",o.enabled)} ${ae("AUTH",o.auth)} URL
152
+ `);for(let s of r)process.stdout.write(`${ae(s.name,o.name)} ${ae(s.enabled,o.enabled)} ${ae(s.auth,o.auth)} ${s.url}
153
+ `)}function ae(e,t){return e.length>=t?e:e+" ".repeat(t-e.length)}async function wn(e){let t=y(e),n=e.positional[0];if(!n)throw new Error("Usage: gs connectors add <name> --url <url> [--token <token>]");let r=h(e.flags,"url");if(!r)throw new Error("--url is required for `gs connectors add`.");let o=h(e.flags,"token"),s=h(e.flags,"profileUrl")??null,i=!m(e.flags,"disabled");if(!m(e.flags,"force")){let u=`${S(t)}/connectors/probe`,f=await d(u,{method:"POST",body:{url:r,...o!==void 0?{token:o}:{},...s!==null?{profileUrl:s}:{}}});if(!f.ok)throw new Error(`Connector did not answer tool discovery${f.error?`: ${f.error}`:""}. Fix the URL/token or pass --force to save it anyway.`);process.stdout.write(`Probe ok \u2014 ${f.toolCount??0} tool(s) discovered.
154
+ `)}let a=await A(t),l={id:"",name:n,url:r,transport:"http",authKind:o?"bearer":"none",enabled:i,profileUrl:s,...o!==void 0?{token:o}:{}},p=(await J(t,a,[...a.connectors.map(F),l])).connectors.find(u=>u.name===n);process.stdout.write(`Added connector "${n}"${p?` (${p.id})`:""} \u2192 ${t}
155
+ `)}async function Sn(e){let t=y(e),n=e.positional[0];if(!n)throw new Error("Usage: gs connectors remove <name|id>");let r=await A(t),o=ie(r,n),s=r.connectors.filter(i=>i.id!==o.id).map(F);await J(t,r,s),process.stdout.write(`Removed connector "${o.name}" from ${t}
156
+ `)}async function He(e,t){let n=y(e),r=e.positional[0];if(!r)throw new Error(`Usage: gs connectors ${t?"enable":"disable"} <name|id>`);let o=await A(n),s=ie(o,r),i=o.connectors.map(a=>a.id===s.id?{...F(a),enabled:t}:F(a));await J(n,o,i),process.stdout.write(`Connector "${s.name}" is now ${t?"enabled":"disabled"}
157
+ `)}async function bn(e){let t=y(e),n=e.positional[0];if(n!=="on"&&n!=="off")throw new Error("Usage: gs connectors maker on|off");let r=await A(t);await J(t,r,r.connectors.map(F),n==="on"),process.stdout.write(`Maker MCP is now ${n}
158
+ `)}async function vn(e){let t=y(e),n=await A(t),r=null,o=e.positional[0];if(o&&(r=ie(n,o).id),n.connectors.length===0){process.stdout.write(`(no custom connectors in ${t})
159
+ `);return}let s=`${S(t)}/connectors/health`,i=await d(s,{method:"POST",body:r?{id:r}:{}});if(m(e.flags,"json")){process.stdout.write(JSON.stringify(i.health,null,2)+`
156
160
  `);return}let a=new Map(n.connectors.map(l=>[l.id,l.name]));for(let l of i.health){let c=a.get(l.id)??l.id;l.ok?process.stdout.write(` ok ${c} (${l.toolCount??0} tools)
157
161
  `):(process.stdout.write(` failed ${c}: ${l.error??"discovery failed"}
158
- `),process.exitCode=1)}}async function bn(e){let t=e.positional[0]??"list",n={...e,positional:e.positional.slice(1)};switch(t){case"list":await mn(n);return;case"add":await gn(n);return;case"remove":await hn(n);return;case"enable":await De(n,!0);return;case"disable":await De(n,!1);return;case"maker":await yn(n);return;case"health":await wn(n);return;default:throw new Error(`Unknown connectors subcommand: ${t}. Use \`gs connectors [add|remove|enable|disable|maker|health]\`.`)}}function Sn(e,t=15){if(!e.trim())return"";let n=e.split(`
162
+ `),process.exitCode=1)}}async function xn(e){let t=e.positional[0]??"list",n={...e,positional:e.positional.slice(1)};switch(t){case"list":await yn(n);return;case"add":await wn(n);return;case"remove":await Sn(n);return;case"enable":await He(n,!0);return;case"disable":await He(n,!1);return;case"maker":await bn(n);return;case"health":await vn(n);return;default:throw new Error(`Unknown connectors subcommand: ${t}. Use \`gs connectors [add|remove|enable|disable|maker|health]\`.`)}}function kn(e,t=15){if(!e.trim())return"";let n=e.split(`
159
163
  `),r=[],o=0,s=!1;for(let i of n){if(i.startsWith("## ")){if(s&&o>=t)break;s=!0}r.push(i),s&&/^\s*[-*+]\s/.test(i)&&o++}return r.join(`
160
- `).trimEnd()}var Ur=`# Changelog
164
+ `).trimEnd()}var Kr=`# Changelog
161
165
 
162
166
  All notable changes to \`@greatstore/cli\` are recorded here. The format
163
167
  follows [Keep a Changelog](https://keepachangelog.com/).
164
168
 
169
+ ## 0.1.11 \u2014 2026-09-14
170
+
171
+ ### Added
172
+ - \`gs apps rename <old> <new>\` renames a component without republishing it:
173
+ its versions and live state carry over, and a local \`components/<old>/\`
174
+ folder is renamed to match.
175
+
165
176
  ## 0.1.10 \u2014 2026-09-13
166
177
 
167
178
  ### Changed
@@ -641,7 +652,7 @@ follows [Keep a Changelog](https://keepachangelog.com/).
641
652
 
642
653
  ### Fixed
643
654
  - Sign-in callback parameter handling.
644
- `,vn=`gs \u2014 GreatStore CLI (v${F})
655
+ `,Pn=`gs \u2014 GreatStore CLI (v${N})
645
656
 
646
657
  Usage:
647
658
  gs <command> [args] [flags]
@@ -667,9 +678,9 @@ Store administration:
667
678
  connectors maker on|off Toggle the Maker MCP.
668
679
  connectors health [<name>] Live-probe saved connectors.
669
680
  apps <subcommand> Author and ship custom in-chat apps (init, build,
670
- list, pull, push, publish, unpublish, delete).
671
- \`gs apps help\` lists them; each also works at the
672
- top level (\`gs push\` == \`gs apps push\`).
681
+ list, pull, push, publish, unpublish, rename, delete).
682
+ \`gs apps help\` lists them; all but rename also work
683
+ at the top level (\`gs push\` == \`gs apps push\`).
673
684
 
674
685
  Agent tooling:
675
686
  skill Print how to install the GreatStore agent skill,
@@ -695,14 +706,14 @@ Environment:
695
706
  GS_API_BASE Override API base (full URL, no trailing slash).
696
707
  GS_DASHBOARD_BASE Override the sign-in/store-picker base URL.
697
708
  GS_BROWSER_CMD Override the browser-open command.
698
- `,Gr=new Set(["init","build","list","pull","push","publish","unpublish","delete"]);async function qr(){let e=process.argv.slice(2),t=Be(e);if(m(t.flags,"version")){process.stdout.write(`gs v${F}
709
+ `,Wr=new Set(["init","build","list","pull","push","publish","unpublish","delete"]);async function zr(){let e=process.argv.slice(2),t=Me(e);if(m(t.flags,"version")){process.stdout.write(`gs v${N}
699
710
 
700
- `);let n=Sn(Ur);return n&&process.stdout.write(`${n}
701
- `),0}if(m(t.flags,"help")||t.command==="help"||t.command===null){let n=t.command==="configure"?lt(t.positional[0]):void 0;return process.stdout.write(n??vn),0}if(t.command!==null&&Gr.has(t.command))return Fe({...t,positional:[t.command,...t.positional]});switch(t.command){case"login":return await Ze(t),0;case"logout":return et(),0;case"whoami":return tt();case"switch":return nt(t.positional);case"apps":return Fe(t);case"configure":return await dn(t),0;case"connectors":return await bn(t),0;case"skill":return at(),0;default:return process.stderr.write(`Unknown command: ${t.command}
711
+ `);let n=kn(Kr);return n&&process.stdout.write(`${n}
712
+ `),0}if(m(t.flags,"help")||t.command==="help"||t.command===null){let n=t.command==="configure"?pt(t.positional[0]):void 0;return process.stdout.write(n??Pn),0}if(t.command!==null&&Wr.has(t.command))return De({...t,positional:[t.command,...t.positional]});switch(t.command){case"login":return await tt(t),0;case"logout":return nt(),0;case"whoami":return rt();case"switch":return ot(t.positional);case"apps":return De(t);case"configure":return await hn(t),0;case"connectors":return await xn(t),0;case"skill":return lt(),0;default:return process.stderr.write(`Unknown command: ${t.command}
702
713
 
703
- ${vn}`),1}}qr().then(e=>process.exit(e)).catch(e=>{e instanceof L?process.stderr.write(`${e.message}
704
- `):e instanceof N?process.stderr.write(`Error: ${e.message}
705
- `):e instanceof D||e instanceof V?process.stderr.write(`Error: ${e.message}
714
+ ${Pn}`),1}}zr().then(e=>process.exit(e)).catch(e=>{e instanceof O?process.stderr.write(`${e.message}
715
+ `):e instanceof D?process.stderr.write(`Error: ${e.message}
716
+ `):e instanceof B||e instanceof K?process.stderr.write(`Error: ${e.message}
706
717
  `):e instanceof Error?process.stderr.write(`Error: ${e.message}
707
718
  `):process.stderr.write(`Error: ${String(e)}
708
719
  `),process.exit(1)});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@greatstore/cli",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "CLI for administering GreatStore stores and authoring custom components.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",