@greatstore/cli 0.2.0 → 0.2.3

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.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: greatstore
3
- description: Build AI-powered shopping experiences with GreatStore on a merchant's website and store. Use when installing the GreatStore chat widget on a site, generating AI content for custom UI with generateStructuredContent, adding chat entry points (sendMessage), letting the assistant act on the page via WebMCP page tools (document.modelContext.registerTool), authoring custom in-chat apps with the gs CLI, administering the store from the CLI (gs configure, gs connectors — origin allowlists, CSP hosts, MCP connectors), setting up web push re-engagement, or connecting AI agents to a store's MCP endpoints. Covers setup, schema design, caching behavior, app authoring, store administration, and ready-made recipes.
3
+ description: Build AI-powered shopping experiences with GreatStore on a merchant's website and store. Use when installing the GreatStore chat widget on a site, generating AI content for custom UI with generateStructuredContent, adding chat entry points (sendMessage), letting the assistant act on the page via WebMCP page tools (document.modelContext.registerTool), authoring custom in-chat apps with the gs CLI, administering the store from the CLI (npx greatstore configure, npx greatstore connectors — origin allowlists, CSP hosts, MCP connectors), setting up web push re-engagement, or connecting AI agents to a store's MCP endpoints. Covers setup, schema design, caching behavior, app authoring, store administration, and ready-made recipes.
4
4
  ---
5
5
 
6
6
  # Building with GreatStore
@@ -32,7 +32,7 @@ constraints) that the references spell out.
32
32
  | Expand an app's image in an **on-brand full-screen lightbox** | an app's `onShowLightbox({ src, originRect })` | [references/apps.md](references/apps.md) |
33
33
  | **Re-engage shoppers** with browser notifications | merchant-hosted `gs.js` + `enableNotifications()` | [references/push-notifications.md](references/push-notifications.md) |
34
34
  | Connect **AI agents** to the store (shopping tools over MCP, CLI docs for coding agents) | the store's MCP endpoints | [references/agents-and-mcp.md](references/agents-and-mcp.md) |
35
- | **Administer the store** — read config/connectors to ground decisions; self-serve origin allowlists and CSP hosts | `gs configure`, `gs connectors` | [references/store-admin.md](references/store-admin.md) |
35
+ | **Administer the store** — read config/connectors to ground decisions; self-serve origin allowlists and CSP hosts | `npx greatstore configure`, `npx greatstore connectors` | [references/store-admin.md](references/store-admin.md) |
36
36
 
37
37
  ## Three things to know before any of it
38
38
 
@@ -24,14 +24,19 @@ const data = await window.GreatStore.generateStructuredContent(
24
24
  headline: { type: "string", maxLength: 60 },
25
25
  subline: { type: "string", maxLength: 120 },
26
26
  featuredProductName: { type: "string", nullable: true },
27
- ctaChatMessage: { type: "string", maxLength: 120 },
27
+ ctaChatMessage: {
28
+ type: "string",
29
+ maxLength: 120,
30
+ description:
31
+ "The first-person message a shopper would send to start shopping " +
32
+ "for the spotlighted product or category",
33
+ },
28
34
  },
29
35
  required: ["headline", "subline", "ctaChatMessage"],
30
36
  },
31
37
  `Variant ${week}. Write a homepage hero for this store: a headline and ` +
32
38
  `subline spotlighting a real product or category that fits the current ` +
33
- `season, plus ctaChatMessage — the first-person message a shopper ` +
34
- `would send to start shopping for it.`
39
+ `season, and a message for the shopper to start a chat with.`
35
40
  );
36
41
 
37
42
  heroHeadline.textContent = data.headline;
@@ -7,10 +7,7 @@
7
7
  > as-is.
8
8
 
9
9
  The flagship pattern: an AI-generated quiz card in your design, whose answers
10
- drop the shopper into a chat that can act on the page. Uses the
11
- `onGreatStoreReady` helper from the
12
- [embed API reference](../references/embed-api.md#availability) — define
13
- that once and it works for every use on the page.
10
+ drop the shopper into a chat that can act on the page.
14
11
 
15
12
  ```html
16
13
  <section id="gift-finder" hidden>
@@ -19,15 +16,9 @@ that once and it works for every use on the page.
19
16
  </section>
20
17
 
21
18
  <script>
22
- // Depending on where this script tag sits relative to the embed script
23
- // tag, this inline script could run either before embed.js has executed
24
- // at all, or after it's already mounted — checking `window.GreatStore`
25
- // synchronously and bailing if it's not there yet would silently skip
26
- // the whole funnel in the first case, and a bare
27
- // `addEventListener("greatstore:ready", ...)` would silently miss the
28
- // (one-shot, already-fired) event in the second.
29
- // onGreatStoreReady (see the embed API reference) handles both.
30
- onGreatStoreReady(async (gs) => {
19
+ // Works whether this runs before or after the embed script: a listener
20
+ // attached once GreatStore is already ready still receives the event.
21
+ window.addEventListener("greatstore:ready", async ({ detail: gs }) => {
31
22
  // Tools the resulting conversation can use — discovered on its next
32
23
  // turn automatically.
33
24
  document.modelContext.registerTool({
@@ -88,7 +79,7 @@ that once and it works for every use on the page.
88
79
  }
89
80
  document.getElementById("gift-finder").hidden = false;
90
81
  } catch {}
91
- });
82
+ }, { once: true });
92
83
  </script>
93
84
  ```
94
85
 
@@ -7,15 +7,12 @@
7
7
  > as-is.
8
8
 
9
9
  Give every conversation on the site real capabilities. Register once in a
10
- shared snippet, after the SDK is ready (which guarantees
11
- `document.modelContext` exists) — using the `onGreatStoreReady` helper from
12
- the [embed API reference](../references/embed-api.md#availability), which
13
- handles both load orderings (embed script not run yet vs. already mounted)
14
- that a plain `window.GreatStore?.ready.then()` or a bare
15
- `addEventListener("greatstore:ready", ...)` each only cover one side of:
10
+ shared snippet, once GreatStore is ready (which guarantees
11
+ `document.modelContext` exists). The listener works whether the snippet runs
12
+ before or after the embed script:
16
13
 
17
14
  ```js
18
- onGreatStoreReady(() => {
15
+ window.addEventListener("greatstore:ready", () => {
19
16
  const text = (value) => ({
20
17
  content: [{ type: "text", text: JSON.stringify(value) }],
21
18
  });
@@ -72,7 +69,7 @@ onGreatStoreReady(() => {
72
69
  });
73
70
  },
74
71
  });
75
- });
72
+ }, { once: true });
76
73
  ```
77
74
 
78
75
  Principles at work: throw on failure (the assistant explains and recovers),
@@ -9,7 +9,7 @@ Each app is an AI-callable tool: the manifest's `description` tells the
9
9
  assistant *when* to reach for it, its `inputSchema` declares the props the
10
10
  assistant fills in, and a `displayMode` picks where it appears.
11
11
 
12
- Authoring requires store-owner access (`gs login` signs in with the store
12
+ Authoring requires store-owner access (`npx greatstore login` signs in with the store
13
13
  owner's account).
14
14
 
15
15
  ## How an app actually runs
@@ -81,21 +81,20 @@ Four consequences worth designing around:
81
81
  ## Workflow
82
82
 
83
83
  ```
84
- npm install -g @greatstore/cli # or npx @greatstore/cli <command>
85
- gs login # browser sign-in
86
- gs apps init --store my-store # scaffold a project root
84
+ npx greatstore login # browser sign-in
85
+ npx greatstore apps init --store my-store # scaffold a project root
87
86
  cd <project> && npm install
88
- gs apps init size_guide # scaffold components/size_guide/
87
+ npx greatstore apps init size_guide # scaffold components/size_guide/
89
88
  # … edit components/size_guide/{component.tsx,manifest.json} …
90
- gs apps build # bundle every app
91
- gs apps push # upload changed apps as drafts
92
- gs apps publish size_guide # promote to live
89
+ npx greatstore apps build # bundle every app
90
+ npx greatstore apps push # upload changed apps as drafts
91
+ npx greatstore apps publish size_guide # promote to live
93
92
  ```
94
93
 
95
- `gs apps list` shows what's deployed (with dashboard links); `gs apps pull`
96
- round-trips live apps back to disk. `gs apps push` hashes apps and only
94
+ `npx greatstore apps list` shows what's deployed (with dashboard links); `npx greatstore apps pull`
95
+ round-trips live apps back to disk. `npx greatstore apps push` hashes apps and only
97
96
  uploads what changed. (The subcommands also work at the top level —
98
- `gs push` == `gs apps push`.) On disk each app is a folder under
97
+ `npx greatstore push` == `npx greatstore apps push`.) On disk each app is a folder under
99
98
  `components/`, holding `manifest.json` and `component.tsx`.
100
99
 
101
100
  The scaffold writes an `AGENTS.md` into the project (with `CLAUDE.md` /
@@ -182,6 +181,11 @@ name yours for the distinct thing it does (`show_catalog_inline` alongside
182
181
  - `fullscreen` — takes over the full preview surface; persists until the
183
182
  next widget-emitting tool call or an explicit close.
184
183
 
184
+ **Safe-zone for `fullscreen` apps.** The floating chat widget sits over the
185
+ bottom of a fullscreen app, covering whatever is rendered there. Leave
186
+ `6.25em` (100px at the default font size) of bottom padding on the app's
187
+ scrolling content so everything can be scrolled clear of it.
188
+
185
189
  ## The app contract
186
190
 
187
191
  `component.tsx` default-exports a React component. Its props are the
@@ -81,12 +81,24 @@ characters) are silently ignored and fall back to the configured default.
81
81
  | `slug` | `string` | The store identifier the script was loaded for. |
82
82
  | `host` | `string` | `"greatstore.ai"`. |
83
83
  | `embedHost` | `string` | Origin the embed assets load from, e.g. `https://<slug>.greatstore.ai`. |
84
- | `ready` | `Promise<void>` | Resolves when the chat UI has mounted and `open()` would render instantly. Resolved promises replay, so `.then()` works no matter when it's attached. The readiness signal to gate on. |
85
84
 
86
- A `greatstore:ready` `CustomEvent` (with the SDK object as `detail`) is also
87
- dispatched on `window` at the moment `ready` resolves, for declarative
88
- tooling. Unlike the promise, the listener must be attached before mount
89
- completes — attach it before (or immediately after) the embed script tag.
85
+ ## Readiness: the `greatstore:ready` event
86
+
87
+ A `greatstore:ready` `CustomEvent` (with the SDK object as `detail`) is
88
+ dispatched on `window` once the chat UI has mounted and `open()` would render
89
+ instantly. It is the signal to gate on, and it works no matter when the
90
+ listener is attached: a listener added after GreatStore is ready receives the
91
+ event once, straight away.
92
+
93
+ ```js
94
+ window.addEventListener(
95
+ "greatstore:ready",
96
+ () => {
97
+ button.hidden = false;
98
+ },
99
+ { once: true },
100
+ );
101
+ ```
90
102
 
91
103
  ## Methods
92
104
 
@@ -204,21 +216,21 @@ navigating away from the only route that should show it.
204
216
  No-ops (with a console warning) if nothing is mounted. The cached identity
205
217
  and downloaded chat bundle are kept, so a later `load()` (or any call that
206
218
  triggers a mount, like `open()`) mounts a fresh panel without a network
207
- round-trip for either. `ready` becomes a new pending promise at the moment
208
- `destroy()` is called, resolving again once the next mount completes:
219
+ round-trip for either. `greatstore:ready` fires again once the next mount
220
+ completes:
209
221
 
210
222
  ```js
211
223
  window.GreatStore.destroy();
212
224
  // ...later, on the page/route where the embed should come back:
225
+ window.addEventListener("greatstore:ready", onRemounted, { once: true });
213
226
  window.GreatStore.load();
214
- await window.GreatStore.ready; // resolves once the fresh mount is done
215
227
  ```
216
228
 
217
229
  ## Page tools — WebMCP (`document.modelContext`)
218
230
 
219
231
  The recommended way to expose page capabilities to the assistant is the
220
232
  WebMCP standard. The GreatStore assistant uses every tool registered on
221
- `document.modelContext` **once GreatStore is ready** (see `onGreatStoreReady`
233
+ `document.modelContext` **once GreatStore is ready** (see [Availability](#availability)
222
234
  below), re-reading the list on each conversational turn — so tools
223
235
  registered mid-session appear on the next message without a reload. Tools
224
236
  registered before GreatStore is ready are ignored.
@@ -234,45 +246,20 @@ position, which matters if the page also has another script (a nav widget,
234
246
  an analytics tag) registering its own WebMCP tools: whichever executes
235
247
  first wins that registration, and only a synchronous, unconditionally-first
236
248
  script gives GreatStore's fallback shim a real chance of installing before
237
- one of those calls happens. That said, your own code can still end up on
238
- either side of two different races relative to `embed.js`, depending on
239
- where your script tag sits and whether it uses `async`/`defer` itself:
240
-
241
- - **Your script runs before `embed.js` has executed at all** — `window.GreatStore`
242
- doesn't exist yet. `window.GreatStore?.ready` silently evaluates to
243
- `undefined` here (optional chaining swallows it), so accessing `.then()`
244
- on it throws or (written more defensively) just does nothing.
245
- - **Your script runs after `embed.js` has already mounted** — the
246
- `greatstore:ready` event already fired once, in the past.
247
- `window.addEventListener("greatstore:ready", ...)` attached now will
248
- never see it: the event isn't replayed for late listeners, unlike a
249
- resolved Promise (`.then()` on an already-resolved Promise still fires).
250
-
251
- Neither `.ready.then(...)` alone nor `addEventListener("greatstore:ready", ...)`
252
- alone is safe against both orderings. Use both, picking whichever is valid
253
- at the moment your code runs:
249
+ one of those calls happens. Your own code
250
+ can still run on either side of `embed.js` — before it has executed at all
251
+ (`window.GreatStore` doesn't exist yet), or long after it has mounted (a lazily rendered component, a
252
+ tag manager). Listening for `greatstore:ready` covers both: a listener
253
+ attached after GreatStore is already ready still receives the event, once.
254
254
 
255
255
  ```js
256
- function onGreatStoreReady(callback) {
257
- if (window.GreatStore?.ready) {
258
- // embed.js has already run — .then() on its ready Promise fires
259
- // immediately if it already resolved, or once it does.
260
- window.GreatStore.ready.then(() => callback(window.GreatStore));
261
- } else {
262
- // embed.js hasn't run yet — wait for the one-shot event it'll dispatch
263
- // once it has. Safe to attach now: nothing can fire it between this
264
- // check and the listener attaching, since JS execution isn't preemptible.
265
- window.addEventListener(
266
- "greatstore:ready",
267
- (event) => callback(event.detail),
268
- { once: true },
269
- );
270
- }
271
- }
272
-
273
- onGreatStoreReady(() => {
274
- document.modelContext.registerTool(/* … */);
275
- });
256
+ window.addEventListener(
257
+ "greatstore:ready",
258
+ () => {
259
+ document.modelContext.registerTool(/* … */);
260
+ },
261
+ { once: true },
262
+ );
276
263
  ```
277
264
 
278
265
  (`navigator.modelContext` is a deprecated alias for the same object; use
@@ -308,11 +295,10 @@ document.modelContext.registerTool(
308
295
  - **Treat `args` as untrusted input**: values are AI-generated. Validate
309
296
  before passing to your own APIs, and never `eval` anything from them.
310
297
 
311
- A complete tool, registered once GreatStore is ready (using the
312
- `onGreatStoreReady` helper defined above):
298
+ A complete tool, registered once GreatStore is ready:
313
299
 
314
300
  ```js
315
- onGreatStoreReady(() => {
301
+ window.addEventListener("greatstore:ready", () => {
316
302
  document.modelContext.registerTool({
317
303
  name: "add_to_cart",
318
304
  description:
@@ -337,7 +323,7 @@ onGreatStoreReady(() => {
337
323
  return { content: [{ type: "text", text: JSON.stringify(cart) }] };
338
324
  },
339
325
  });
340
- });
326
+ }, { once: true });
341
327
  ```
342
328
 
343
329
  Returning the fresh cart state after the mutation lets the assistant confirm
@@ -380,4 +366,4 @@ in campaign links, emails, and post-login redirects.
380
366
  | Console: `[GreatStore] Embed script must be loaded from <slug>.greatstore.ai/embed.js` | The script was copied/self-hosted instead of loaded from the store's embed URL. Always load it from `https://<slug>.greatstore.ai/embed.js`. |
381
367
  | `generateStructuredContent` rejects with a rate-limit message | More than ~20 requests/minute from one visitor. Consolidate calls into fewer, richer schemas. |
382
368
  | Chat won't auto-open after returning to the page | Intentional: the drawer never auto-opens on resume — it would cover the content the shopper is reading. The transcript is preserved; they'll see it when they tap the launcher. |
383
- | Tools registered but the assistant doesn't use them | Check the `description` — it's the only signal for *when* to call. Also confirm the registration ran (`document.modelContext` exists after `ready`) on the same page the conversation is on. |
369
+ | Tools registered but the assistant doesn't use them | Check the `description` — it's the only signal for *when* to call. Also confirm the registration ran (it runs inside a `greatstore:ready` listener) on the same page the conversation is on. |
@@ -1,8 +1,8 @@
1
1
  # Store administration from the CLI
2
2
 
3
3
  The `gs` CLI is a full admin surface for a GreatStore store, mirroring the
4
- merchant's admin dashboard one-to-one: `gs configure` ↔ the Configure panel,
5
- `gs connectors` ↔ the Connectors panel, `gs apps` ↔ the Apps panel. Same
4
+ merchant's admin dashboard one-to-one: `npx greatstore configure` ↔ the Configure panel,
5
+ `npx greatstore connectors` ↔ the Connectors panel, `npx greatstore apps` ↔ the Apps panel. Same
6
6
  fields, same behaviour — anything you change is what the merchant sees in
7
7
  their dashboard.
8
8
 
@@ -14,8 +14,7 @@ the user to go click through a dashboard.
14
14
  ## Setup
15
15
 
16
16
  ```
17
- npm install -g @greatstore/cli # or npx @greatstore/cli <command>
18
- gs login # one-time browser sign-in (needs a human)
17
+ npx greatstore login # one-time browser sign-in (needs a human)
19
18
  ```
20
19
 
21
20
  Credentials persist across runs. Admin commands take `--store <slug>`
@@ -29,25 +28,25 @@ Reading store state is never destructive. Do it whenever it would improve a
29
28
  decision:
30
29
 
31
30
  ```
32
- gs configure --store my-store --json # brand config
33
- gs connectors --store my-store --json # MCP connectors feeding the assistant
34
- gs connectors health --store my-store # live-probe them (reports tool counts)
35
- gs apps list --store my-store --json # deployed custom in-chat apps
31
+ npx greatstore configure --store my-store --json # brand config
32
+ npx greatstore connectors --store my-store --json # MCP connectors feeding the assistant
33
+ npx greatstore connectors health --store my-store # live-probe them (reports tool counts)
34
+ npx greatstore apps list --store my-store --json # deployed custom in-chat apps
36
35
  ```
37
36
 
38
37
  What each read is good for:
39
38
 
40
- - **`gs configure`** — the store's `extraOrigins` (is the site you're
39
+ - **`npx greatstore configure`** — the store's `extraOrigins` (is the site you're
41
40
  integrating actually allowlisted? — see the embed troubleshooting note in
42
41
  [embed-api.md](embed-api.md)), `theme` (match generated on-page UI to the
43
42
  brand's colors/radius), `storeLink`, and CSP host lists.
44
- - **`gs connectors`** — which MCP connectors the assistant has, and whether
43
+ - **`npx greatstore connectors`** — which MCP connectors the assistant has, and whether
45
44
  the Maker MCP is on. This tells you what the assistant can actually *do*:
46
45
  check it before building features that lean on catalog data (e.g.
47
46
  [structured content](structured-content.md) grounding), and before
48
47
  registering WebMCP page tools that would duplicate a capability a
49
48
  server-side connector already provides.
50
- - **`gs connectors health`** — a connector being listed doesn't mean it's
49
+ - **`npx greatstore connectors health`** — a connector being listed doesn't mean it's
51
50
  reachable; this probes each one live. Run it when assistant behaviour
52
51
  suggests a tool isn't responding.
53
52
 
@@ -67,9 +66,9 @@ make: they're additive, easy to undo, and invisible to shoppers.
67
66
  current value, append yours, write the union:
68
67
 
69
68
  ```
70
- gs configure --store my-store --json
69
+ npx greatstore configure --store my-store --json
71
70
  # extraOrigins is ["https://shop.example.com"] → write both, comma-separated:
72
- gs configure set --store my-store \
71
+ npx greatstore configure set --store my-store \
73
72
  --extraOrigins "https://shop.example.com,https://staging.example.com"
74
73
  ```
75
74
 
@@ -83,9 +82,9 @@ do for every shopper. Propose it, don't do it unprompted:
83
82
 
84
83
  - **Brand-visible config** — `displayName`, `assistantName`, `storeLink`,
85
84
  `theme`, and asset uploads
86
- (`gs configure upload|clear icon|logoLight|logoDark`).
87
- - **Connector mutations** — `gs connectors add|remove|enable|disable` and
88
- `gs connectors maker on|off`. (`add` probes the connector for tool
85
+ (`npx greatstore configure upload|clear icon|logoLight|logoDark`).
86
+ - **Connector mutations** — `npx greatstore connectors add|remove|enable|disable` and
87
+ `npx greatstore connectors maker on|off`. (`add` probes the connector for tool
89
88
  discovery before saving and refuses if it doesn't answer; `--force`
90
89
  overrides. Still: adding capabilities to the merchant's assistant is the
91
90
  merchant's call.)
@@ -99,32 +98,32 @@ and confirm the result with a read.
99
98
  ## Command reference
100
99
 
101
100
  ```
102
- gs configure [--json] show configuration
103
- gs configure set --<field> <value> displayName, assistantName,
101
+ npx greatstore configure [--json] show configuration
102
+ npx greatstore configure set --<field> <value> displayName, assistantName,
104
103
  storeLink, extraOrigins a,b,
105
104
  cspScriptHosts a,b, cspConnectHosts a,b
106
105
  ("" clears a field)
107
- gs configure set --theme.<field> <value> one theme field, merged into the rest:
106
+ npx greatstore configure set --theme.<field> <value> one theme field, merged into the rest:
108
107
  mode auto|light|dark|custom,
109
108
  radius sharp|default|rounded,
110
109
  fontFamily, secondaryFontFamily,
111
110
  mobileBottomBarOffset (px, 0-200), zIndex,
112
111
  brandColor/surfaceColor/textColor and
113
112
  the fine-grained color tokens
114
- gs configure set --theme '<json>' merge a whole object (--themeFile <path>);
113
+ npx greatstore configure set --theme '<json>' merge a whole object (--themeFile <path>);
115
114
  --replace overwrites instead of merging
116
- gs configure set --help every field, its type and legal values
117
- gs configure upload <kind> <file> icon | logoLight | logoDark (.png/.jpg/.webp)
118
- gs configure clear <kind> remove an uploaded asset
115
+ npx greatstore configure set --help every field, its type and legal values
116
+ npx greatstore configure upload <kind> <file> icon | logoLight | logoDark (.png/.jpg/.webp)
117
+ npx greatstore configure clear <kind> remove an uploaded asset
119
118
 
120
- gs connectors [--json] list Maker toggle + custom connectors
121
- gs connectors add <name> --url <url> [--token <t>] [--profileUrl <u>]
119
+ npx greatstore connectors [--json] list Maker toggle + custom connectors
120
+ npx greatstore connectors add <name> --url <url> [--token <t>] [--profileUrl <u>]
122
121
  [--disabled] [--force]
123
- gs connectors remove <name|id>
124
- gs connectors enable|disable <name|id>
125
- gs connectors maker on|off
126
- gs connectors health [<name|id>] [--json]
122
+ npx greatstore connectors remove <name|id>
123
+ npx greatstore connectors enable|disable <name|id>
124
+ npx greatstore connectors maker on|off
125
+ npx greatstore connectors health [<name|id>] [--json]
127
126
 
128
- gs apps <init|build|list|pull|push|publish|unpublish|delete>
127
+ npx greatstore apps <init|build|list|pull|push|publish|unpublish|delete>
129
128
  see apps.md for the workflow
130
129
  ```
@@ -23,9 +23,11 @@ Each is unpacked in the sections below; this is the checklist.
23
23
 
24
24
  1. **Top level must be an object.** Want a list? Wrap it:
25
25
  `{ type: "object", properties: { items: { type: "array", … } }, required: ["items"] }`.
26
- 2. **Steer with the prompt, not schema `description`s** — free-text schema
27
- fields are stripped before the AI sees them. Use self-explanatory
28
- property names (`benefitHeadline`, not `text1`).
26
+ 2. **Steer the whole output with the prompt, single fields with
27
+ `description`.** A property's `description` reaches the AI as guidance for
28
+ that field; it's optional, so use self-explanatory property names
29
+ (`benefitHeadline`, not `text1`) and describe only where the name isn't
30
+ enough.
29
31
  3. **Only `require` what's guaranteed.** `required` is strictly enforced; if
30
32
  the catalog can't ground a required field the whole call can fail. Require
31
33
  structural fields, keep per-product details (image URLs, prices) optional,
@@ -41,8 +43,8 @@ Each is unpacked in the sections below; this is the checklist.
41
43
  provide. Ask for something outside them — currency conversion, live
42
44
  shipping rates, review data the store never wired up — and it has nothing
43
45
  to ground on, so it will decline, omit… or hallucinate. Before writing a
44
- prompt or schema that depends on a data capability, run `gs connectors`
45
- (and `gs connectors health`, [store-admin.md](store-admin.md)) and confirm
46
+ prompt or schema that depends on a data capability, run `npx greatstore connectors`
47
+ (and `npx greatstore connectors health`, [store-admin.md](store-admin.md)) and confirm
46
48
  a connector for it exists; if it doesn't, don't ask for it.
47
49
  6. **Responses are cached** for up to ~24h per page + prompt + schema —
48
50
  shared across anonymous visitors, per-shopper for identified ones. Keep
@@ -66,7 +68,7 @@ Each is unpacked in the sections below; this is the checklist.
66
68
  page's DOM is never read. Research happens on GreatStore's side — your
67
69
  prompt only needs to *point* it at the right SKU, product, or collection,
68
70
  not carry the material. Its reach is exactly the store's MCP connectors:
69
- validate with `gs connectors` ([store-admin.md](store-admin.md)) that a
71
+ validate with `npx greatstore connectors` ([store-admin.md](store-admin.md)) that a
70
72
  connector for the data you want actually exists before you build on it —
71
73
  research can't exceed the wired-up connectors, and prompts that assume
72
74
  otherwise invite hallucinated filler.
@@ -97,31 +99,60 @@ Supported keywords (anything else is tolerated but ignored):
97
99
  - Choice: `enum`, `const`, `anyOf`, `nullable`
98
100
  - Constraints: `minimum`, `maximum`, `minLength`, `maxLength`, `minItems`,
99
101
  `maxItems`, `pattern`, `format`, `default`
102
+ - Guidance: `description`, `example`, `title` (on any property)
100
103
 
101
104
  Validation of the output is real: `required` is enforced, `enum`/`const`
102
105
  must match, numeric and length bounds are checked, and
103
106
  `additionalProperties: false` rejects extra keys. Constraints are therefore a
104
- *tool* — `maxItems: 4` reliably caps a list, `enum` reliably restricts a
105
- field — but every constraint is also a way for generation to fail, so apply
106
- them only where you'd rather have no content than non-conforming content.
107
+ *tool* — `enum` reliably restricts a field — but every constraint is also a
108
+ way for generation to fail, so apply them only where you'd rather have no
109
+ content than non-conforming content.
110
+
111
+ Item counts are the exception. `minItems` is honored as the content is
112
+ written, so a list comes back with at least that many entries, and a list
113
+ longer than `maxItems` is cut to its first `maxItems` entries rather than
114
+ failing. The same applies to an app's `inputSchema`.
107
115
 
108
116
  Zod schemas (or anything with a `.toJSONSchema()` method) are accepted and
109
- converted automatically.
117
+ converted automatically — `.describe("…")` becomes the field's `description`.
118
+
119
+ ### Field descriptions
110
120
 
111
- ### Free-text schema fields are stripped
121
+ A property's `description` is shown to the AI as guidance for that one
122
+ field, and an `example` shows the exact shape you want (`"4.5 out of 5"`,
123
+ `"SKU-1234"`). Both are optional: a field without them is filled from its
124
+ name, the prompt, and its constraints.
125
+
126
+ ```js
127
+ {
128
+ type: "object",
129
+ properties: {
130
+ headline: { type: "string", maxLength: 60 },
131
+ priceJustification: {
132
+ type: "string",
133
+ description: "One sentence on why the price is fair, citing a real material or feature",
134
+ },
135
+ rating: { type: "string", example: "4.5 out of 5" },
136
+ },
137
+ required: ["headline"],
138
+ }
139
+ ```
112
140
 
113
- `description`, `title`, and `example` are removed from the schema before the
114
- AI sees it (they're a prompt-injection surface, so they're filtered
115
- server-side). Consequences:
141
+ Split the work between the two channels:
116
142
 
117
- - Schema descriptions **cannot** steer generation. All steering lives in the
118
- prompt string.
119
- - Property *names* are the only in-schema signal of intent — make them
120
- self-documenting: `ctaLabel`, `warmthRating`, `priceJustification`.
143
+ - **Prompt** — the situation, the task as a whole, grounding, and voice.
144
+ - **`description` / `example`** — what one specific field holds: its unit, length in
145
+ words, perspective ("first-person, as the shopper"), or how it relates to
146
+ a sibling. Instructions that apply to the whole output don't belong here.
147
+ - Property *names* still carry most of the intent — make them
148
+ self-documenting (`ctaLabel`, `warmthRating`, `priceJustification`) and
149
+ reach for a description when the name can't say it.
121
150
 
122
151
  ## Prompting guide
123
152
 
124
- The prompt is the entire instruction channel. A good prompt states, in order:
153
+ The prompt carries the instructions for the output as a whole (per-field
154
+ guidance can sit in each field's `description` or `example`). A good prompt states, in
155
+ order:
125
156
 
126
157
  1. **Context** — what page/situation the shopper is in, naming the entity so
127
158
  research targets the right thing (the AI can't see your DOM, so identify
@@ -154,7 +185,7 @@ Anti-patterns:
154
185
  - **Asking for data no connector provides** ("convert the price to EUR",
155
186
  "estimate delivery to the shopper's city"): research can't exceed the
156
187
  store's MCP connectors, and the AI may hallucinate plausible-looking
157
- values rather than leave the field empty. Validate first — `gs connectors`
188
+ values rather than leave the field empty. Validate first — `npx greatstore connectors`
158
189
  shows what's wired up ([store-admin.md](store-admin.md)); if there's no
159
190
  connector for it, don't ask for it.
160
191
  - **Asking it to read the page** ("summarize the reviews shown below") — it
@@ -165,7 +196,9 @@ Anti-patterns:
165
196
  delivery countdowns). Even when a connector could answer, responses cache
166
197
  for up to ~24h — display operational data from your own platform APIs and
167
198
  use GreatStore for *editorial intelligence over the catalog*.
168
- - **Burying instructions in schema descriptions** — stripped, see above.
199
+ - **Putting whole-output instructions in a field's `description`** (voice,
200
+ grounding, what the page is) — they belong in the prompt, where they apply
201
+ to every field.
169
202
 
170
203
  ## Caching: design for it
171
204
 
@@ -221,7 +254,6 @@ A decline is only ever one of these `error.reason` values — anything else
221
254
  | `harmful` | asks for unsafe, hateful, sexual, or illegal content, or advice that could hurt someone |
222
255
  | `deceptive` | asks for fake reviews, invented discounts or scarcity, claims the catalog contradicts, or impersonating/disparaging a named brand or person |
223
256
  | `system_probe` | asks about or tries to override the assistant's own instructions or tools |
224
- | `no_data` | depends on specific store facts and research found nothing to fill the required fields — check `gs connectors`, or make those fields optional |
225
257
 
226
258
  The uniform shopper-facing strategy: render into a hidden-by-default
227
259
  container, reveal on success, leave hidden (or show your static fallback) on
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@greatstore/cli",
3
- "version": "0.2.0",
3
+ "version": "0.2.3",
4
4
  "description": "CLI for administering GreatStore stores and authoring custom components.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -27,5 +27,8 @@
27
27
  "tsup": "^8.3.0",
28
28
  "typescript": "^5.8.2",
29
29
  "vitest": "^2.1.0"
30
- }
30
+ },
31
+ "publishAliases": [
32
+ "greatstore"
33
+ ]
31
34
  }