greatstore 0.2.24 → 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
 
@@ -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.24",
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",