greatstore 0.2.23 → 0.3.0

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 (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, and store administration.
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), making the store's assistant smarter (npx greatstore knowledge — knowledge base documents, agent instructions, separating instructions from knowledge, fixing an assistant that ignores an instruction, auditing and reorganising a knowledge base, testing it with ask), setting up web push re-engagement, or connecting AI agents to a store's MCP endpoints. Covers setup, schema design, caching behavior, app authoring, and store administration.
4
4
  ---
5
5
 
6
6
  # Building with GreatStore
@@ -34,6 +34,7 @@ constraints) that the references spell out.
34
34
  | **Re-engage shoppers** with browser notifications | merchant-hosted `gs.js` + `enableNotifications()` | [references/push-notifications.md](references/push-notifications.md) |
35
35
  | 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) |
36
36
  | **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) |
37
+ | **Make the assistant smarter** — knowledge base documents, agent instructions, what goes where, fixing an assistant that ignores an instruction, auditing and reorganising the knowledge base, testing it | `npx greatstore knowledge` | [references/knowledge-and-instructions.md](references/knowledge-and-instructions.md) |
37
38
 
38
39
  ## Three things to know before any of it
39
40
 
@@ -46,10 +46,10 @@ CLI commands.
46
46
  claude mcp add --transport http greatstore-admin https://admin.greatstore.ai/mcp
47
47
  ```
48
48
 
49
- Useful when a coding agent is shipping apps
50
- ([apps.md](apps.md)) and needs the exact command for
51
- the next step. If this skill is installed, the agent already has the
52
- workflow — the MCP is the self-serve alternative for agents that don't.
49
+ It is how a merchant hands a coding agent their store: its setup steps have
50
+ the agent install this skill (`npx greatstore skill`) and sign in, and from
51
+ then on the agent works from the skill. If this skill is already installed,
52
+ the agent already has the workflow.
53
53
 
54
54
  ## What to use when
55
55
 
@@ -70,7 +70,7 @@ Four consequences worth designing around:
70
70
  props. Keep the render a function of the props it was given, so a re-call
71
71
  is a re-render rather than a reset.
72
72
  3. **The app can run its own generation, not just receive props.**
73
- `$.generateStructuredContent(schema, prompt, fallback)` gives it a
73
+ `$.generateStructuredContent(schema, prompt, { fallback })` gives it a
74
74
  catalog-grounded, shopper-personalized generation of its own, returned as
75
75
  an object matching your schema — recommended picks, a personalized
76
76
  summary, a reason per option — rendered in the merchant's own markup. Use
@@ -266,7 +266,7 @@ component. Never declare a `$` field in `inputSchema` — the build refuses it.
266
266
  | `$.updateModelContext(context)` | Inject **invisible** background context for the model — the variant the shopper selected, the options they configured, the step they're on. Replaces the prior value (never appends); pass `""` to clear. Read on the next chat turn. Use this instead of `$.sendMessage` when the assistant should *know* state without a message appearing in the transcript. |
267
267
  | `$.callTool(name, args?)` | The page's `window.GreatStore.callTool`, for the app: run one of the page's own WebMCP tools or a read-only connector tool and get its result, or open a full-screen app by name — see [embed-api/call-tool.md](embed-api/call-tool.md) for what it reaches, what comes back, and how to look up tools. Never touches the conversation. In the app preview, tools run for real and naming a full-screen app only logs what would open. Inside other AI assistants (ChatGPT, …) it always rejects — handle the rejection. |
268
268
  | `$.showLightbox({ src, originRect? })` | Expand an image in the chat's shared full-screen lightbox — an on-brand zoom overlay you can't render yourself (your app is 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). |
269
- | `$.generateStructuredContent(schema, prompt, fallback)` | Ask the store's assistant for content matching a JSON Schema (or Zod schema) and get back the generated object. Personalized to the shopper. Works the same in the conversation on the storefront and every embed. Best for async apps that build their render from a generated payload. `fallback` is **required**: a schema-shaped object you provide that the app preview renders (no live store there), validated against the schema — a mismatch throws. |
269
+ | `$.generateStructuredContent(schema, prompt, { fallback, prefetch })` | Ask the store's assistant for content matching a JSON Schema (or Zod schema) and get back the generated object. Personalized to the shopper. Works the same in the conversation on the storefront and every embed. Best for async apps that build their render from a generated payload. `fallback` is **required**: a schema-shaped object you provide that the app preview renders (no live store there), validated against the schema — a mismatch throws. `prefetch` is optional: the lookups the content needs when the app already knows them, which makes it ready sooner — see [embed-api/generate-structured-content.md](embed-api/generate-structured-content.md#prefetching-what-the-page-knows). |
270
270
  | `$.close()` | Dismiss the host slot. `over-input` clears the overlay, `fullscreen` reverts the pane, `inline` is a no-op. |
271
271
  | `$.useVoiceCall()` | A hook — call it at the top of your component like any other — returning `{ status, available, start, end }` for a voice call with the store's assistant. `start()` starts the call without opening the chat — it runs in the collapsed chat bar (which stays hidden if the store hides the chat until opened), and the chat opens only when the assistant shows an inline app (call it from a click; it rejects when the store has no voice), `end()` hangs up. `available` says whether the store has voice. `status` is `null` until a call starts, then `started`, `connecting`, `connected`, `listening` / `speaking` / `working` as the conversation goes, `disconnected` while the network drops (the call recovers on its own), and `ended` — or `rejected` instead of `ended` when the shopper refuses the microphone (calling `start()` again asks again, though a browser where they blocked it refuses without asking). Your app re-renders on every change. |
272
272
  | `$.Image` | A drop-in for `<img>` — render `<Image src=… alt=… />` and the image is served at the right size for the store. Takes the same props as `<img>`. |
@@ -1,4 +1,4 @@
1
- # `generateStructuredContent(schema: object, prompt: string): Promise<unknown>`
1
+ # `generateStructuredContent(schema: object, prompt: string, options?: { prefetch? }): Promise<unknown>`
2
2
 
3
3
  Generates JSON matching `schema` from `prompt`, grounded in the store's live
4
4
  catalog, for UI the page renders itself — the chat panel is not involved.
@@ -14,6 +14,8 @@ const data = await window.GreatStore.generateStructuredContent(schema, prompt);
14
14
  exposing `.toJSONSchema()` (e.g. a Zod schema); the conversion is called
15
15
  for you, and `.describe("…")` becomes the field's `description`.
16
16
  - `prompt` — what to generate.
17
+ - `options.prefetch` — optional: the lookups the content needs, when the page
18
+ already knows them. See [Prefetching what the page knows](#prefetching-what-the-page-knows).
17
19
 
18
20
  Rejects immediately if `prompt` is not a non-empty string or `schema` is not
19
21
  an object.
@@ -35,7 +37,9 @@ Each is unpacked in the sections below; this is the checklist.
35
37
  its own — name the entity (`` `…the product "${productName}" (SKU ${sku})` ``)
36
38
  and let it look the facts up. The one thing it *can't* see is your page,
37
39
  so page-only context (which page the shopper is on, what the section is
38
- for) does belong in the prompt.
40
+ for) does belong in the prompt. When the page already knows exactly which
41
+ lookup the content needs — the product it shows, by ID — name it in
42
+ `prefetch` instead, and the content comes back sooner.
39
43
  5. **Research is bounded by the store's connectors — validate before you
40
44
  build.** Ask for something no connector provides — currency conversion,
41
45
  live shipping rates, review data the store never wired up — and it has
@@ -74,7 +78,9 @@ Each is unpacked in the sections below; this is the checklist.
74
78
  availability, store info) using read-only lookups. The page context only
75
79
  hints at which product or category to look up — it is *not* a source of
76
80
  product data, and nothing else on the page (visible text, reviews, your
77
- markup) is read. Its reach is exactly the store's MCP connectors.
81
+ markup) is read. Its reach is exactly the store's MCP connectors. With
82
+ `prefetch`, the lookups you named are the whole research: nothing else is
83
+ looked up.
78
84
  3. The AI fills your schema from the researched data under a strict
79
85
  grounding contract: it must not invent product names, prices, images, IDs,
80
86
  or descriptions. Fields it can't ground are omitted or `null`. For an
@@ -87,6 +93,33 @@ Each is unpacked in the sections below; this is the checklist.
87
93
  Because GreatStore already knows who's reading, never put shopper data in
88
94
  the prompt — it's redundant, and it poisons the cache key.
89
95
 
96
+ ## Prefetching what the page knows
97
+
98
+ A product page knows its product; a category page knows its category. Name
99
+ those lookups in `prefetch` and GreatStore runs them straight away rather
100
+ than working out what to look up, which makes an uncached call noticeably
101
+ faster:
102
+
103
+ ```js
104
+ const data = await window.GreatStore.generateStructuredContent(schema, prompt, {
105
+ prefetch: [{ name: "get_product_details", args: { id: productId } }],
106
+ });
107
+ ```
108
+
109
+ - Each entry is `{ name, args }` — the same read-only connector tools, with
110
+ the same arguments, that [`callTool`](call-tool.md) runs. Look them up with
111
+ `npx greatstore connectors tools <connector> --store <slug>`.
112
+ - Up to 5 entries. An empty list is the same as leaving `prefetch` out.
113
+ - They are the **whole** lookup: content is written from their results alone.
114
+ Name everything the schema needs, or leave `prefetch` out and let GreatStore
115
+ find it.
116
+ - A name that isn't a read-only connector tool rejects at once, with `code`
117
+ `call_tool_unknown` or `call_tool_not_read_only`. A malformed list rejects
118
+ with `prefetch_invalid`.
119
+ - A lookup that fails (a wrong ID, a wrong argument) leaves the content
120
+ without that data, which usually means a decline with `insufficient_data`.
121
+ - `prefetch` is part of the cache key, like the prompt and schema.
122
+
90
123
  ## Schema support
91
124
 
92
125
  Top level **must describe an object**: `type: "object"` (or a bare
@@ -247,7 +280,7 @@ Anti-patterns:
247
280
 
248
281
  ## Caching
249
282
 
250
- Responses are cached server-side for up to **24 hours**, keyed by page
283
+ Responses are cached server-side, keyed by page
251
284
  context (URL path, title, JSON-LD identifiers) + prompt + schema. Anonymous
252
285
  visitors share one entry per key; identified shoppers each get their own
253
286
  (their output may be personalized, so it's only ever served back to them).
@@ -265,16 +298,19 @@ call behaves the same either way.
265
298
 
266
299
  Practical consequences:
267
300
 
268
- - **The first render pays, repeats fly.** Expect a few seconds on a cache
269
- miss and near-instant responses after. The catalog research underneath is
301
+ - **The first render pays, repeats fly.** Expect a few seconds the first
302
+ time a call is made and near-instant responses after — including after the
303
+ content is due a refresh, which is prepared for the next visit while this
304
+ one gets the previous answer. The catalog research underneath is
270
305
  also cached briefly and shared, so even misses — and several distinct
271
306
  surfaces on one page — are cheaper than cold. Design loading states for
272
307
  the miss case.
273
308
  - **Same call on different pages = different content**, automatically — the
274
309
  page path is in the key and in the AI's hints. A single site-wide snippet
275
310
  with a constant prompt yields per-page content for free.
276
- - **Content refreshes roughly daily.** Don't build experiences that assume
277
- minute-level freshness.
311
+ - **Content refreshes roughly daily**, on the first visit after it is due, so
312
+ a rarely visited page can show content up to a week old. Don't build
313
+ experiences that assume minute-level freshness.
278
314
  - **To force different content, change the prompt or schema** (e.g. a
279
315
  campaign variant string that changes weekly — deliberate, low-cardinality
280
316
  variation is fine; per-visitor cardinality is not).
@@ -116,7 +116,7 @@ and replay in order.
116
116
  | `callTool(name, args)` | Run one of the page's own WebMCP tools, open a full-screen app from the page, or fetch data from a connector's read-only tool. | [embed-api/call-tool.md](embed-api/call-tool.md) |
117
117
  | `on(event, handler)` | Subscribe to panel and voice events. | [embed-api/events.md](embed-api/events.md) |
118
118
  | `startVoiceCall()`, `endVoiceCall()` | Start or hang up a voice call without opening the chat. | [embed-api/voice-call.md](embed-api/voice-call.md) |
119
- | `generateStructuredContent(schema, prompt)` | Generate catalog-grounded JSON for the page's own UI. | [embed-api/generate-structured-content.md](embed-api/generate-structured-content.md) |
119
+ | `generateStructuredContent(schema, prompt, { prefetch }?)` | Generate catalog-grounded JSON for the page's own UI. | [embed-api/generate-structured-content.md](embed-api/generate-structured-content.md) |
120
120
  | `enableNotifications()` | Opt the browser into the store's push notifications. | [embed-api/enable-notifications.md](embed-api/enable-notifications.md) |
121
121
  | `document.modelContext.registerTool(tool)` | Let the assistant act on the page (WebMCP page tools). | [embed-api/webmcp.md](embed-api/webmcp.md) |
122
122
 
@@ -0,0 +1,240 @@
1
+ # Making the store's assistant smarter
2
+
3
+ A store's assistant draws on two things the merchant controls:
4
+
5
+ - **Agent instructions** apply to every reply. They are how the assistant
6
+ behaves: its tone, its rules, what it prioritises, what it always or never
7
+ does.
8
+ - **The knowledge base** is what the assistant looks things up in when a
9
+ question calls for it: policies, product details, sizing, care guides, FAQs,
10
+ store information.
11
+
12
+ Most "the assistant got it wrong" problems come from material in the wrong
13
+ place. A rule saved as a knowledge source is only in front of the assistant
14
+ when a question happens to bring that source up, so it gets followed some of
15
+ the time. A pile of facts saved as instructions crowds out the rules that
16
+ matter. Keep each in its place and both work better.
17
+
18
+ Everything here uses `npx greatstore knowledge` (alias `kb`). It takes
19
+ `--store <slug>` or reads the nearest `.gsrc`, like the other admin commands
20
+ (see [store-admin.md](store-admin.md)). Run `npx greatstore knowledge --help`
21
+ for every flag.
22
+
23
+ ## Instructions or knowledge?
24
+
25
+ Ask of each sentence: **does it tell the assistant how to act, or what is
26
+ true?**
27
+
28
+ | It's an instruction (how to act) | It's knowledge (what is true) |
29
+ |---|---|
30
+ | "Mention free returns when someone hesitates over a purchase." | "Returns are free within 30 days of delivery." |
31
+ | "Recommend the Pro range to anyone asking about trail running." | "The Pro range has a Vibram outsole and a 6 mm drop." |
32
+ | "Answer in a warm, brief tone; one short paragraph unless asked for more." | Brand story, About page, founder bio. |
33
+ | "Before suggesting a size, ask for the shopper's usual size in another brand." | The size chart and fit notes. |
34
+ | "Hand off to support@example.com for order changes." | Shipping times, carriers, delivery regions. |
35
+
36
+ A second test: **would the sentence still matter if the shopper never asked
37
+ about its topic?** "Always offer gift wrapping at checkout" matters on every
38
+ purchase, so it's an instruction. "Gift wrapping costs $5" only matters when
39
+ gift wrapping comes up, so it's knowledge.
40
+
41
+ ### Splitting a mixed document
42
+
43
+ Merchants often upload one document that holds both, such as a returns policy
44
+ ending with "staff should always remind customers that returns are free".
45
+ Split it:
46
+
47
+ 1. Keep the facts in the knowledge base, with the rule removed
48
+ (`knowledge edit <source> --old "<the rule>" --new ""`).
49
+ 2. Add the rule to the instructions, reworded as an instruction to the
50
+ assistant (`knowledge instructions edit`, below).
51
+
52
+ Don't copy facts into the instructions "to be safe". Point at them instead:
53
+ "When asked about returns, explain the policy and mention that returns are
54
+ free" is enough, and the details come from the knowledge base.
55
+
56
+ ## Writing instructions that get followed
57
+
58
+ - **Specific beats general.** "Be helpful" changes nothing. "When a shopper
59
+ asks for a gift idea, ask who it's for and their budget before suggesting
60
+ products" changes every gift conversation.
61
+ - **Say what to do.** Describe the behaviour you want, rather than listing the
62
+ phrasings to avoid. "Refer to the brand as Acme Outdoor" works better than a
63
+ list of names not to use.
64
+ - **Give the reason.** "Recommend in-stock sizes only, because back-orders take
65
+ six weeks" lets the assistant handle cases the rule didn't spell out.
66
+ - **One rule, one place.** Two rules that say almost the same thing, or that
67
+ pull in different directions, get followed inconsistently. Merge them.
68
+ - **Most important first**, and keep the whole thing short. Instructions are
69
+ limited to 8,000 characters, and a focused page is followed far more
70
+ reliably than a long one.
71
+ - **No facts that change.** Prices, stock, dates and promotions belong in the
72
+ knowledge base or the catalog, where updating them doesn't mean touching the
73
+ rules.
74
+
75
+ ## Keeping the knowledge base healthy
76
+
77
+ - **One topic per source.** A "Shipping" source and a "Returns" source
78
+ serve the assistant better than one "Policies" document covering ten things.
79
+ - **Name sources for what's in them.** "Returns and exchanges policy" beats
80
+ "policy_v3_final". `add` requires `--name` for a single source; with several
81
+ files at once, each is named after its file, so name the files well.
82
+ - **Check that it worked.** Processing takes a moment. Use `--wait` on `add`,
83
+ `edit` and `reindex`, or run `knowledge status`. A failed source prints why.
84
+ `reindex` it, or for a web page that can't be read, add its text as a note
85
+ instead (`add --text`).
86
+ - **Update instead of duplicating.** Two versions of the same policy give the
87
+ assistant two answers. Edit the existing source (below), or remove the
88
+ outdated one.
89
+ - **Web pages are a snapshot.** A page added with `--url` doesn't follow later
90
+ changes to the site. `reindex` it to read the page again.
91
+
92
+ ## Editing safely
93
+
94
+ Both sources and instructions are edited the way a coding agent edits a file:
95
+
96
+ ```
97
+ npx greatstore knowledge show "Returns and exchanges policy" # text on stdout, hash on stderr
98
+ npx greatstore knowledge edit "Returns and exchanges policy" \
99
+ --old "within 30 days" --new "within 60 days" --wait
100
+
101
+ npx greatstore knowledge instructions # current instructions + hash
102
+ npx greatstore knowledge instructions edit \
103
+ --old "Answer briefly." --new "Answer briefly, and end with one follow-up question."
104
+ ```
105
+
106
+ `--old` must match the stored text exactly and occur exactly once. If someone
107
+ changed it since you read it, the edit is refused. Read it again, then retry
108
+ against the current text. `--new ""` deletes the matched text.
109
+
110
+ To rewrite everything, save the text to a file, edit it, and send it back
111
+ with the hash you read:
112
+
113
+ ```
114
+ npx greatstore knowledge instructions > instructions.md # prints "hash: <h>" on stderr
115
+ # …edit instructions.md…
116
+ npx greatstore knowledge instructions set --file instructions.md --expect <h> --unsafe-upload
117
+ ```
118
+
119
+ `instructions set` refuses without `--unsafe-upload`, because it turns a local
120
+ file into what the assistant follows on every reply. Pass it only once the user
121
+ has approved the new instructions, and only for the file you wrote for them.
122
+
123
+ The same works for a text source: `knowledge edit <source> --file <path>
124
+ --expect <hash> --unsafe-upload`, with the same rule for the flag: the user has
125
+ approved the new text, and the file is the one you wrote for it. Only text sources (notes, Markdown and plain-text files) can
126
+ be edited. To change a PDF or Word document, upload the new version and remove
127
+ the old one.
128
+
129
+ ## Testing with `ask`
130
+
131
+ `knowledge ask` sends a message to the store's live assistant, with the same
132
+ instructions, knowledge and tools a shopper gets, and prints its reply and the
133
+ tools it used:
134
+
135
+ ```
136
+ npx greatstore knowledge ask "Can I return shoes I've worn outside?"
137
+ npx greatstore knowledge ask "What if they're a gift?" --conversation <id>
138
+ ```
139
+
140
+ Each reply prints the `--conversation` id that continues it. Use it to test
141
+ rules that only apply later in a conversation. Starting a new `ask` ends your
142
+ previous test conversation. `ask` uses the store's credits like any reply, so
143
+ test with a few pointed questions rather than many.
144
+
145
+ The store's test chats share an allowance of 100 credits in any 6 hours,
146
+ counting the dashboard's own previews too. Every `ask` reply ends with how much
147
+ of it is used and how much is left. When it runs out, `ask` is refused until
148
+ older tests fall out of the 6 hours. Plan your test questions to fit, and tell
149
+ the user if you can't finish testing.
150
+
151
+ ## Auditing and reorganising the knowledge base
152
+
153
+ When the user asks you to review the knowledge base, or the assistant's answers
154
+ are generally weak, audit it end to end before changing anything:
155
+
156
+ 1. **Take inventory.** Run `knowledge list --json` and `knowledge instructions`.
157
+ Note any failed sources and why they failed.
158
+ 2. **Read every source** with `show`. A source that can't be shown as text is
159
+ an uploaded document kept in its original format. Note it, and judge it by
160
+ its name and by what `ask` gets out of it.
161
+ 3. **Sort what you read.** For each passage, decide whether it's a fact or a
162
+ rule (see *Instructions or knowledge?*), and which topic it belongs to.
163
+ 4. **List the problems:**
164
+ - rules buried in sources
165
+ - facts crowding the instructions
166
+ - two sources covering the same topic, or contradicting each other
167
+ - outdated content (old prices, past promotions, discontinued products)
168
+ - sources mixing several topics
169
+ - names that don't say what's inside
170
+ - failed sources
171
+ - obvious gaps, such as shipping mentioned everywhere but described nowhere
172
+ 5. **Write a baseline.** Pick 5–10 questions a shopper would really ask that
173
+ these sources should answer, including one or two that touch an
174
+ instruction. Run each with `ask` and keep the replies.
175
+ 6. **Propose a plan to the merchant.** Show the target layout (one topic per
176
+ source, with names) and each change as before and after: which sources to
177
+ split, merge, edit, rename or remove, and what moves into or out of the
178
+ instructions. Also list the gaps that need content only the merchant has.
179
+ Make no changes until they agree.
180
+ 7. **Make the changes in small steps.** Add the new sources first (with
181
+ `--wait`), then edit, and remove the old ones last, so nothing is missing
182
+ in between. Check `status` when you're done.
183
+ 8. **Measure.** Run the same baseline questions again and report what changed:
184
+ better answers, regressions, and anything still unanswered.
185
+
186
+ Keep the audit's own `ask` runs to the baseline set, plus a re-run after.
187
+ Every run uses the store's credits and counts against the test-chat allowance
188
+ (see *Testing with `ask`*), so check what's left before starting.
189
+
190
+ ## When the assistant ignores an instruction
191
+
192
+ Work through these in order, and stop when it's fixed:
193
+
194
+ 1. **Reproduce it.** Find a message that shows the problem with `ask`. If the
195
+ rule applies mid-conversation, set the conversation up first with
196
+ `--conversation`. Without a reproduction you can't tell whether a change
197
+ helped.
198
+ 2. **Find where the rule lives.** Read the instructions
199
+ (`knowledge instructions`) and search the sources (`knowledge list`, then
200
+ `show` the likely ones). A rule that only exists inside a knowledge source
201
+ is followed only when that source comes up, so move it into the
202
+ instructions (see *Splitting a mixed document*).
203
+ 3. **Look for contradictions.** Check whether another instruction, or a
204
+ knowledge source, says something different. Examples are an old policy
205
+ document, a duplicated rule with different wording, or a general rule
206
+ ("keep answers to one sentence") that overrides a specific one ("explain
207
+ the full returns process"). Remove or reconcile the conflict.
208
+ 4. **Rewrite the rule.** Make it one specific instruction that says what to
209
+ do, when, and why (see *Writing instructions that get followed*). Move it
210
+ near the top if it matters more than what's above it. Delete vague or
211
+ duplicate rules around it.
212
+ 5. **Check the facts it relies on.** If the rule says "mention the warranty"
213
+ but no source describes the warranty, the assistant has nothing to
214
+ mention. Add the source.
215
+ 6. **Test again** with the same `ask` messages, plus one where the rule
216
+ should *not* apply, to make sure it doesn't now fire everywhere.
217
+
218
+ If it still fails after this, report what you tried and the exact `ask`
219
+ exchange to the merchant rather than piling on more rules.
220
+
221
+ ## What you may change without asking
222
+
223
+ - **Freely:** every read (`list`, `status`, `show`, `instructions`), and `ask`
224
+ to test (a few turns; it uses credits).
225
+ - **When the task calls for it:** adding web pages (`add --url`) and notes you
226
+ wrote from what the user told you (`add --text`). Report what you added.
227
+ - **Only for a file the user named:** uploading a local file (`add <file>`,
228
+ `add --text-file`). Its contents become something the assistant can quote to
229
+ any shopper, so a file holding anything private (contracts, supplier prices,
230
+ staff or customer details, internal notes) must never go in. The command
231
+ refuses without `--unsafe-upload`. Pass that flag only when the user has
232
+ named this exact file for the knowledge base in this conversation. Never pass
233
+ it for a file you found yourself; ask first, naming the file and what's in it.
234
+ - **Only with the merchant's go-ahead:** editing, renaming, reindexing or
235
+ removing sources, and any change to the agent instructions. These change how
236
+ the live assistant answers every shopper. Propose the exact change, showing
237
+ the before and after text and why, and make it once they agree. When the user
238
+ has explicitly asked for the change ("make the assistant always mention free
239
+ returns"), that's the go-ahead. Make it, then confirm with a read and an
240
+ `ask`.
@@ -2,7 +2,8 @@
2
2
 
3
3
  The `gs` CLI is a full admin surface for a GreatStore store, mirroring the
4
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
5
+ `npx greatstore connectors` ↔ the Connectors panel, `npx greatstore knowledge` ↔ the
6
+ Knowledge panel, `npx greatstore apps` ↔ the Apps panel. Same
6
7
  fields, same behaviour — anything you change is what the merchant sees in
7
8
  their dashboard.
8
9
 
@@ -35,6 +36,8 @@ npx greatstore connectors tools maker --store my-store # a connector's tools, i
35
36
  npx greatstore connectors tools webmcp --store my-store # the page tools the store's pages register
36
37
  npx greatstore connectors errors --store my-store --json # tools' most frequent errors, last 7 days
37
38
  npx greatstore apps list --store my-store --json # deployed custom in-chat apps
39
+ npx greatstore knowledge --store my-store --json # knowledge sources and their status
40
+ npx greatstore knowledge instructions --store my-store # the agent instructions
38
41
  ```
39
42
 
40
43
  What each read is good for:
@@ -68,6 +71,12 @@ What each read is good for:
68
71
  here when debugging a tool you built or wired up — `--tool <name>` narrows to
69
72
  it, `--days N` widens the window (up to 120).
70
73
 
74
+ - **`npx greatstore knowledge`** — what the assistant knows and the
75
+ instructions it follows. Read them before building anything that leans on
76
+ the assistant's answers. `knowledge ask "<message>"` tests the live
77
+ assistant. It uses the store's credits, so keep it to a few turns. See
78
+ [knowledge-and-instructions.md](knowledge-and-instructions.md).
79
+
71
80
  ## Safe to change without asking
72
81
 
73
82
  When the task the user gave you requires it, these changes are yours to
@@ -79,6 +88,12 @@ make: they're additive, easy to undo, and invisible to shoppers.
79
88
  - **`cspScriptHosts` / `cspConnectHosts`** — hosts the storefront accepts
80
89
  for scripts/connections. Add a host when an app
81
90
  legitimately needs a third-party SDK or API.
91
+ - **Adding web pages and notes to the knowledge base**
92
+ (`npx greatstore knowledge add --url` / `--text`) when the task needs them.
93
+ Check they finished processing (`--wait`) and report what you added.
94
+ Uploading a local file is different: its contents become shareable with
95
+ shoppers, so it needs `--unsafe-upload`, which you pass only for a file the
96
+ user named (see [knowledge-and-instructions.md](knowledge-and-instructions.md)).
82
97
 
83
98
  **List flags replace the stored list — always read-merge-write.** Fetch the
84
99
  current value, append yours, write the union:
@@ -106,6 +121,9 @@ do for every shopper. Propose it, don't do it unprompted:
106
121
  discovery before saving and refuses if it doesn't answer; `--force`
107
122
  overrides. Still: adding capabilities to the merchant's assistant is the
108
123
  merchant's call.)
124
+ - **Knowledge and instruction changes** — `npx greatstore knowledge edit|rename|reindex|remove`
125
+ and `npx greatstore knowledge instructions edit|set`. These change how the
126
+ assistant answers every shopper. Show the merchant the before and after text.
109
127
  - **Anything that clears** — passing `""` to empty a field, removing list
110
128
  entries, `clear`ing assets.
111
129
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "greatstore",
3
- "version": "0.2.23",
3
+ "version": "0.3.0",
4
4
  "description": "CLI for administering GreatStore stores and authoring custom components.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",