greatstore 0.2.12 → 0.2.14
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 +19 -0
- package/README.md +3 -7
- package/dist/cli.js +116 -90
- package/dist/gs-skill/SKILL.md +6 -27
- package/dist/gs-skill/references/apps.md +3 -1
- package/dist/gs-skill/references/embed-api/call-tool.md +57 -0
- package/dist/gs-skill/references/embed-api/enable-notifications.md +13 -0
- package/dist/gs-skill/references/embed-api/events.md +13 -0
- package/dist/gs-skill/references/embed-api/generate-structured-content.md +15 -0
- package/dist/gs-skill/references/embed-api/panel.md +33 -0
- package/dist/gs-skill/references/embed-api/send-message.md +20 -0
- package/dist/gs-skill/references/embed-api/update-model-context.md +27 -0
- package/dist/gs-skill/references/embed-api/voice-call.md +40 -0
- package/dist/gs-skill/references/embed-api/webmcp.md +124 -0
- package/dist/gs-skill/references/embed-api.md +14 -289
- package/dist/gs-skill/references/store-admin.md +8 -2
- package/dist/gs-skill/references/structured-content.md +36 -16
- package/package.json +1 -1
- package/dist/gs-skill/recipes/ask-about-this.md +0 -31
- package/dist/gs-skill/recipes/campaign-hero.md +0 -48
- package/dist/gs-skill/recipes/comparison-table.md +0 -80
- package/dist/gs-skill/recipes/complete-the-look.md +0 -59
- package/dist/gs-skill/recipes/gift-finder-funnel.md +0 -88
- package/dist/gs-skill/recipes/launchers.md +0 -109
- package/dist/gs-skill/recipes/page-action-suite.md +0 -87
- package/dist/gs-skill/recipes/product-faq.md +0 -58
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
# Gift finder funnel (teaser → conversation → action)
|
|
2
|
-
|
|
3
|
-
> **Treat this code as a reference, not a drop-in.** Samples are
|
|
4
|
-
> framework-free vanilla JS so they stay portable — re-express the same
|
|
5
|
-
> logic in the conventions of the repo you're working in (React, Vue,
|
|
6
|
-
> Shopify Liquid sections, Svelte, …) instead of retrofitting the sample
|
|
7
|
-
> as-is.
|
|
8
|
-
|
|
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.
|
|
11
|
-
|
|
12
|
-
```html
|
|
13
|
-
<section id="gift-finder" hidden>
|
|
14
|
-
<h3 id="gf-question"></h3>
|
|
15
|
-
<div id="gf-options"></div>
|
|
16
|
-
</section>
|
|
17
|
-
|
|
18
|
-
<script>
|
|
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 }) => {
|
|
22
|
-
// Tools the resulting conversation can use — discovered on its next
|
|
23
|
-
// turn automatically.
|
|
24
|
-
document.modelContext.registerTool({
|
|
25
|
-
name: "go_to_product",
|
|
26
|
-
description:
|
|
27
|
-
"Navigate the shopper to a product page on this site. Use when " +
|
|
28
|
-
"the shopper picks a product they want to see.",
|
|
29
|
-
inputSchema: {
|
|
30
|
-
type: "object",
|
|
31
|
-
properties: { url: { type: "string" } },
|
|
32
|
-
required: ["url"],
|
|
33
|
-
},
|
|
34
|
-
execute({ url }) {
|
|
35
|
-
const u = new URL(String(url), location.origin);
|
|
36
|
-
if (u.origin !== location.origin) throw new Error("Only same-site URLs allowed");
|
|
37
|
-
location.assign(u.href);
|
|
38
|
-
return { content: [{ type: "text", text: "Navigating." }] };
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
try {
|
|
43
|
-
const data = await gs.generateStructuredContent(
|
|
44
|
-
{
|
|
45
|
-
type: "object",
|
|
46
|
-
properties: {
|
|
47
|
-
question: { type: "string", maxLength: 80 },
|
|
48
|
-
options: {
|
|
49
|
-
type: "array",
|
|
50
|
-
minItems: 3,
|
|
51
|
-
maxItems: 4,
|
|
52
|
-
items: {
|
|
53
|
-
type: "object",
|
|
54
|
-
properties: {
|
|
55
|
-
label: { type: "string", maxLength: 30 },
|
|
56
|
-
chatMessage: { type: "string", maxLength: 140 },
|
|
57
|
-
},
|
|
58
|
-
required: ["label", "chatMessage"],
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
required: ["question", "options"],
|
|
63
|
-
},
|
|
64
|
-
"Create one engaging gift-finder opening question for this store, " +
|
|
65
|
-
"with 3-4 answer options that map to real areas of the catalog. " +
|
|
66
|
-
"For each option also write chatMessage: the message a shopper " +
|
|
67
|
-
"would send to a shopping assistant after picking it, phrased in " +
|
|
68
|
-
"first person (e.g. \"I'm shopping for my dad who loves hiking\")."
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
document.getElementById("gf-question").textContent = data.question;
|
|
72
|
-
const wrap = document.getElementById("gf-options");
|
|
73
|
-
for (const opt of data.options) {
|
|
74
|
-
const btn = document.createElement("button");
|
|
75
|
-
btn.type = "button";
|
|
76
|
-
btn.textContent = opt.label;
|
|
77
|
-
btn.addEventListener("click", () => gs.sendMessage(opt.chatMessage));
|
|
78
|
-
wrap.append(btn);
|
|
79
|
-
}
|
|
80
|
-
document.getElementById("gift-finder").hidden = false;
|
|
81
|
-
} catch {}
|
|
82
|
-
}, { once: true });
|
|
83
|
-
</script>
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
Why it works: the teaser costs one cached generation per page, each
|
|
87
|
-
click opens a conversation that already has direction, and `go_to_product`
|
|
88
|
-
lets the conversation end on a product page instead of in a dead end.
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
# GreatStore launchers — AI question chips
|
|
2
|
-
|
|
3
|
-
> **Treat this code as a reference, not a drop-in.** Samples are
|
|
4
|
-
> framework-free vanilla JS so they stay portable — re-express the same
|
|
5
|
-
> logic in the conventions of the repo you're working in (React, Vue,
|
|
6
|
-
> Shopify Liquid sections, Svelte, …) instead of retrofitting the sample
|
|
7
|
-
> as-is.
|
|
8
|
-
|
|
9
|
-
A horizontally scrollable row of chips, each a highly engaging first-person
|
|
10
|
-
question about the current page. Tapping a chip sends that question to the
|
|
11
|
-
assistant — `generateStructuredContent` writes the questions, `sendMessage`
|
|
12
|
-
fires them. Simple yet effective: it works on every page type, costs one
|
|
13
|
-
cached generation per page, and every tap starts a conversation that already
|
|
14
|
-
has a great opening line.
|
|
15
|
-
|
|
16
|
-
```html
|
|
17
|
-
<div id="gs-launchers" hidden></div>
|
|
18
|
-
|
|
19
|
-
<style>
|
|
20
|
-
#gs-launchers {
|
|
21
|
-
display: flex;
|
|
22
|
-
gap: 0.5em;
|
|
23
|
-
overflow-x: auto;
|
|
24
|
-
-webkit-overflow-scrolling: touch;
|
|
25
|
-
scrollbar-width: none;
|
|
26
|
-
padding: 0.5em 1em;
|
|
27
|
-
}
|
|
28
|
-
#gs-launchers::-webkit-scrollbar { display: none; }
|
|
29
|
-
#gs-launchers button {
|
|
30
|
-
flex: 0 0 auto;
|
|
31
|
-
white-space: nowrap;
|
|
32
|
-
border: 1px solid #ddd;
|
|
33
|
-
border-radius: 999px;
|
|
34
|
-
padding: 0.5em 0.9em;
|
|
35
|
-
background: #fff;
|
|
36
|
-
cursor: pointer;
|
|
37
|
-
}
|
|
38
|
-
</style>
|
|
39
|
-
|
|
40
|
-
<script>
|
|
41
|
-
(async () => {
|
|
42
|
-
const gs = window.GreatStore;
|
|
43
|
-
if (!gs?.generateStructuredContent) return;
|
|
44
|
-
try {
|
|
45
|
-
const data = await gs.generateStructuredContent(
|
|
46
|
-
{
|
|
47
|
-
type: "object",
|
|
48
|
-
properties: {
|
|
49
|
-
launchers: {
|
|
50
|
-
type: "array", minItems: 4, maxItems: 6,
|
|
51
|
-
items: {
|
|
52
|
-
type: "object",
|
|
53
|
-
properties: {
|
|
54
|
-
chip: { type: "string", maxLength: 32 },
|
|
55
|
-
question: { type: "string", maxLength: 140 },
|
|
56
|
-
},
|
|
57
|
-
required: ["chip", "question"],
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
required: ["launchers"],
|
|
62
|
-
},
|
|
63
|
-
`The shopper is on the page "${document.title}". Write 4-6 launcher ` +
|
|
64
|
-
`chips for a shopping assistant. For each, "question" is a highly ` +
|
|
65
|
-
`engaging first-person question this shopper would genuinely want ` +
|
|
66
|
-
`answered on this page — specific to its product, category, or ` +
|
|
67
|
-
`content, never generic — and "chip" is a 2-4 word teaser of it. ` +
|
|
68
|
-
`Vary the angles: fit and use, comparisons, gifting, care, what's ` +
|
|
69
|
-
`popular.`
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
const row = document.getElementById("gs-launchers");
|
|
73
|
-
for (const { chip, question } of data.launchers) {
|
|
74
|
-
const btn = document.createElement("button");
|
|
75
|
-
btn.type = "button";
|
|
76
|
-
btn.textContent = chip;
|
|
77
|
-
btn.title = question;
|
|
78
|
-
btn.addEventListener("click", () => gs.sendMessage(question));
|
|
79
|
-
row.append(btn);
|
|
80
|
-
}
|
|
81
|
-
row.hidden = false;
|
|
82
|
-
} catch {}
|
|
83
|
-
})();
|
|
84
|
-
</script>
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
Why it works:
|
|
88
|
-
|
|
89
|
-
- **The chip is the teaser, the question is the payload.** A 2-4 word chip
|
|
90
|
-
scans instantly; the full first-person question lands in the transcript
|
|
91
|
-
reading like something the shopper typed, and gives the assistant a
|
|
92
|
-
well-formed prompt. The `title` attribute previews the full question on
|
|
93
|
-
hover.
|
|
94
|
-
- **Per-page for free.** The page URL is part of the generation context and
|
|
95
|
-
the cache key, so one site-wide snippet yields different chips on every
|
|
96
|
-
page — each served from cache on repeat renders.
|
|
97
|
-
- **Placement is the lever.** Under the product title, above the grid on
|
|
98
|
-
collections, at the end of a blog post — wherever a shopper pauses to
|
|
99
|
-
wonder, the chips name the question for them.
|
|
100
|
-
|
|
101
|
-
Tips:
|
|
102
|
-
|
|
103
|
-
- Inline the product or collection name into the prompt when the platform
|
|
104
|
-
exposes it — it beats relying on `document.title`.
|
|
105
|
-
- Restyle the chips to the site's design system; the CSS above is just the
|
|
106
|
-
scroll mechanics (flex row, `overflow-x: auto`, hidden scrollbars,
|
|
107
|
-
`white-space: nowrap`).
|
|
108
|
-
- Resist adding more than ~6 chips — a launcher row is an invitation, not a
|
|
109
|
-
sitemap.
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
# Page-action suite (WebMCP)
|
|
2
|
-
|
|
3
|
-
> **Treat this code as a reference, not a drop-in.** Samples are
|
|
4
|
-
> framework-free vanilla JS so they stay portable — re-express the same
|
|
5
|
-
> logic in the conventions of the repo you're working in (React, Vue,
|
|
6
|
-
> Shopify Liquid sections, Svelte, …) instead of retrofitting the sample
|
|
7
|
-
> as-is.
|
|
8
|
-
|
|
9
|
-
Give every conversation on the site real capabilities. Register once in a
|
|
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:
|
|
13
|
-
|
|
14
|
-
```js
|
|
15
|
-
window.addEventListener("greatstore:ready", () => {
|
|
16
|
-
const text = (value) => ({
|
|
17
|
-
content: [{ type: "text", text: JSON.stringify(value) }],
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
document.modelContext.registerTool({
|
|
21
|
-
name: "get_cart",
|
|
22
|
-
description:
|
|
23
|
-
"Read the shopper's current cart on this site: items, quantities, " +
|
|
24
|
-
"and totals. Use before answering any cart question.",
|
|
25
|
-
inputSchema: { type: "object", properties: {} },
|
|
26
|
-
async execute() {
|
|
27
|
-
return text(await (await fetch("/cart.js")).json());
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
document.modelContext.registerTool({
|
|
32
|
-
name: "add_to_cart",
|
|
33
|
-
description:
|
|
34
|
-
"Add a product variant to the cart on this site. Use when the " +
|
|
35
|
-
"shopper asks to add or buy something. Confirm the variant with " +
|
|
36
|
-
"the shopper first if ambiguous.",
|
|
37
|
-
inputSchema: {
|
|
38
|
-
type: "object",
|
|
39
|
-
properties: {
|
|
40
|
-
variantId: { type: "string" },
|
|
41
|
-
quantity: { type: "integer", minimum: 1, maximum: 10 },
|
|
42
|
-
},
|
|
43
|
-
required: ["variantId"],
|
|
44
|
-
},
|
|
45
|
-
async execute({ variantId, quantity }) {
|
|
46
|
-
if (!variantId) throw new Error("variantId is required");
|
|
47
|
-
const res = await fetch("/cart/add.js", {
|
|
48
|
-
method: "POST",
|
|
49
|
-
headers: { "Content-Type": "application/json" },
|
|
50
|
-
body: JSON.stringify({ id: variantId, quantity: quantity ?? 1 }),
|
|
51
|
-
});
|
|
52
|
-
if (!res.ok) throw new Error(`Could not add to cart (${res.status})`);
|
|
53
|
-
document.dispatchEvent(new CustomEvent("cart:refresh"));
|
|
54
|
-
return text(await res.json());
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
document.modelContext.registerTool({
|
|
59
|
-
name: "get_current_page",
|
|
60
|
-
description:
|
|
61
|
-
"Read what page the shopper is currently on, including structured " +
|
|
62
|
-
"product data when on a product page.",
|
|
63
|
-
inputSchema: { type: "object", properties: {} },
|
|
64
|
-
execute() {
|
|
65
|
-
return text({
|
|
66
|
-
url: location.href,
|
|
67
|
-
title: document.title,
|
|
68
|
-
productJson: document.querySelector("#product-json")?.textContent ?? null,
|
|
69
|
-
});
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
}, { once: true });
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
Principles at work: throw on failure (the assistant explains and recovers),
|
|
76
|
-
return fresh state after mutations (the assistant confirms accurately), cap
|
|
77
|
-
quantities in the schema, and notify your own UI (`cart:refresh`) so the
|
|
78
|
-
page reflects what the AI did.
|
|
79
|
-
|
|
80
|
-
For a product-page-only tool, register with an `AbortSignal` and abort on
|
|
81
|
-
SPA navigation:
|
|
82
|
-
|
|
83
|
-
```js
|
|
84
|
-
const ac = new AbortController();
|
|
85
|
-
document.modelContext.registerTool(reviewsTool, { signal: ac.signal });
|
|
86
|
-
router.onLeave("/products/:handle", () => ac.abort());
|
|
87
|
-
```
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
# Product FAQ accordion
|
|
2
|
-
|
|
3
|
-
> **Treat this code as a reference, not a drop-in.** Samples are
|
|
4
|
-
> framework-free vanilla JS so they stay portable — re-express the same
|
|
5
|
-
> logic in the conventions of the repo you're working in (React, Vue,
|
|
6
|
-
> Shopify Liquid sections, Svelte, …) instead of retrofitting the sample
|
|
7
|
-
> as-is.
|
|
8
|
-
|
|
9
|
-
```js
|
|
10
|
-
const data = await window.GreatStore.generateStructuredContent(
|
|
11
|
-
{
|
|
12
|
-
type: "object",
|
|
13
|
-
properties: {
|
|
14
|
-
faqs: {
|
|
15
|
-
type: "array", minItems: 3, maxItems: 5,
|
|
16
|
-
items: {
|
|
17
|
-
type: "object",
|
|
18
|
-
properties: {
|
|
19
|
-
question: { type: "string", maxLength: 90 },
|
|
20
|
-
answer: { type: "string", maxLength: 300 },
|
|
21
|
-
},
|
|
22
|
-
required: ["question", "answer"],
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
required: ["faqs"],
|
|
27
|
-
},
|
|
28
|
-
`Generate the questions shoppers most plausibly have before buying the ` +
|
|
29
|
-
`product "${productName}", with accurate answers grounded in the real ` +
|
|
30
|
-
`product details and store policies. Skip any question the store data ` +
|
|
31
|
-
`can't answer confidently.`
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
const wrap = document.getElementById("gs-faq");
|
|
35
|
-
for (const { question, answer } of data.faqs) {
|
|
36
|
-
const details = document.createElement("details");
|
|
37
|
-
const summary = document.createElement("summary");
|
|
38
|
-
summary.textContent = question;
|
|
39
|
-
const p = document.createElement("p");
|
|
40
|
-
p.textContent = answer;
|
|
41
|
-
details.append(summary, p);
|
|
42
|
-
wrap.append(details);
|
|
43
|
-
}
|
|
44
|
-
wrap.hidden = false;
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
Engagement bonus — append a hand-off row so unanswered questions become
|
|
48
|
-
conversations:
|
|
49
|
-
|
|
50
|
-
```js
|
|
51
|
-
const ask = document.createElement("button");
|
|
52
|
-
ask.type = "button";
|
|
53
|
-
ask.textContent = "Have a different question? Ask us";
|
|
54
|
-
ask.addEventListener("click", () =>
|
|
55
|
-
window.GreatStore.sendMessage(`I have a question about "${productName}".`)
|
|
56
|
-
);
|
|
57
|
-
wrap.append(ask);
|
|
58
|
-
```
|