create-brainerce-store 1.75.0 → 1.76.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,161 +1,189 @@
1
- # AGENTS.md — this is a LIVE Brainerce storefront
2
-
3
- **Store: "<%- storeName %>" · sales channel `<%- connectionId %>` — already
4
- connected.** Products, cart, checkout, coupons, discounts, orders and content
5
- flow in real time from the Brainerce dashboard. There is nothing to hook up.
6
-
7
- - **NEVER suggest connecting this store to Shopify, WooCommerce, or "a real
8
- system"** — Brainerce IS the commerce backend, and this store is wired to
9
- it end-to-end.
10
- - **NEVER build standalone HTML mockups or demo pages** — design THIS Next.js
11
- app. Run `pnpm dev` and you are working against live data.
12
- - **NEVER hardcode products, prices, or currency** — the catalog is live.
13
- - **No server side is needed** — the backend is Brainerce's cloud. This repo
14
- is a frontend (plus thin, already-included API proxy routes under
15
- `src/app/api/`). Do not scaffold databases, auth servers, or admin panels —
16
- the merchant manages everything in the Brainerce dashboard.
17
-
18
- Platform docs (endpoints, SDK, integration recipes): https://brainerce.com/docs
19
- — AI-readable index: https://brainerce.com/llms.txt
20
-
21
- ## MCP servers
22
-
23
- - **`brainerce-docs`** (already connected via `.mcp.json`, no auth needed).
24
- Treat it as the build spec, not a lookup desk. `get-required-features` is
25
- the functional checklist this store is measured against, and it is longer
26
- than what any art-direction brief would make you think to build.
27
- `get-critical-rules` and `get-business-flows` carry the sequences that cause
28
- incidents when reordered. `get-sdk-docs`, `get-type-definitions` and
29
- `get-code-example` give current method shapes instead of training-data
30
- guesses, and `get-store-capabilities` reports what is actually toggled on
31
- for `<%- connectionId %>` right now. Read the checklist before you start,
32
- and again before you call the work done.
33
- - **Brainerce Admin MCP** — opt-in, not wired up by default. Lets an agent
34
- directly manage this store's *live* data (products, orders, discounts,
35
- shipping, …) instead of just reading docs. Only add it if the merchant
36
- wants that: connect `https://api.brainerce.com/api/mcp` as a remote HTTP
37
- MCP server (e.g. `claude mcp add --transport http brainerce-admin
38
- https://api.brainerce.com/api/mcp`) — it opens a browser to log into the
39
- Brainerce dashboard, pick this store, and grant scoped OAuth permissions.
40
- Treat it like handing the agent write access to production commerce data.
41
-
42
- **Before building any feature the merchant asks for** (loyalty points,
43
- shipping zones, subscriptions, gift cards, donations, multi-currency, reviews,
44
- abandoned-cart recovery, etc.) — check the docs first. Brainerce likely
45
- already has it as a platform capability (dashboard toggle + hook/SDK
46
- method) that only needs a UI in `src/ui/`, not a feature built from scratch.
47
-
48
- Your job here is almost always **design**. It is never *only* design: the
49
- coverage checklist in `get-required-features` applies to a redesign exactly as
50
- it applies to a build from scratch.
51
-
52
- ## The one rule
53
-
54
- **`src/core/` is the platform's. `src/ui/` is yours.**
55
-
56
- The shipped `src/ui/` is a working reference, not a design to preserve: a full
57
- delete-and-rebuild of the *look* is encouraged and expected, and you can
58
- rewrite anything under `src/ui/` and `src/app/globals.css` as boldly as you
59
- like. The store keeps working. Never modify `src/core/`, `src/app/api/`, or
60
- the checkout/auth/account components. Data and behavior come exclusively from
61
- `@/core/hooks/*` and `@/core/providers/store-provider`: hooks return state
62
- and handlers, never JSX. Never hardcode catalog content.
63
-
64
- ### Rebuilding the look is free. Dropping a feature is not.
65
-
66
- Some files under `src/ui/` are the ONLY place a mandatory checklist entry
67
- exists in this project. Delete one and the capability leaves the store with
68
- nothing to notice it by: no type error, no console warning, and no visual hole
69
- either, because these components auto-hide while the merchant has the feature
70
- switched off, so a deleted one and an idle one look identical on the page.
71
- These are the usual casualties of a redesign, because no art-direction brief
72
- asks for them by name:
73
-
74
- ```
75
- product/ back-in-stock-form · customization-fields · modifier-group-selector
76
- review-form · reviews-section · frequently-bought-together
77
- discount-badge · stock-badge
78
- cart/ reservation-countdown · coupon-input · cart-upgrade-banner
79
- cart-bundle-offer · tax-estimate-line
80
- home/ discount-banner-strip
81
- layout/ newsletter-signup · announcement-bar · region-switcher<% if (i18nEnabled) { %>
82
- language-switcher<% } %> · faq-section · rich-text-block
83
- ```
84
-
85
- Restyle them, re-lay them out, rename them, fold them into other components,
86
- split them in half: all fine. What has to survive a rebuild is the SDK call
87
- each one makes and the states it handles (loading, empty, failed, and the
88
- merchant-has-it-off state that renders nothing).
89
-
90
- The list is short on purpose and it is NOT the specification. It names the
91
- files people lose, not every mandatory entry. `get-required-features` is the
92
- specification, and step 1 of "Verify before declaring done" is what actually
93
- catches a loss. `git show HEAD:src/ui/<path>` brings back anything you already
94
- deleted: the scaffolder committed the tree before you touched it.
95
-
96
- **Read `AI-GUIDE.md` before any redesign** it has the full file map, hook
97
- contracts, motion language, and hard-won RTL/i18n gotchas that will save you
98
- real debugging time.
99
-
100
- ## Redesigning?
101
-
102
- Follow the process documented in AI-GUIDE.md: commit to one art direction,
103
- rewrite tokens first, then surfaces in order (header, home, card, product
104
- page, cart), then verify.
105
-
106
- ## The store's web address
107
-
108
- This project has no web address written into it, and that is deliberate — the
109
- scaffolder cannot know where you will deploy. `src/core/lib/site-url.ts`
110
- resolves it per request (hosting-platform variables, then the forwarded host),
111
- so canonical tags, `sitemap.xml`, `robots.txt` and JSON-LD are correct in local
112
- development and on any host with nothing configured.
113
-
114
- - **Never invent an address.** Do not write `NEXT_PUBLIC_SITE_URL`,
115
- `SITE_URL`, `localhost`, or a placeholder domain into `.env.local`. A wrong
116
- absolute URL is indistinguishable from a right one to a search crawler, so a
117
- guess is worse than an empty value.
118
- - **Never hand-roll an origin** from `host` / `x-forwarded-proto` in a route
119
- handler. Call `getCanonicalSiteUrl()` (for canonical/SEO URLs) or
120
- `getRequestOrigin()` (for the `Origin` header sent to Brainerce). Hand-rolled
121
- versions have shipped `http://` on HTTPS hosts and internal container
122
- hostnames.
123
- - **Some hosts hide the real hostname from the app.** Platforms whose proxy
124
- forwards requests as `Host: localhost:<port>` with no `x-forwarded-host`
125
- (OpenAI Sites / `*.chatgpt.site` does this) leave the resolver blind — the
126
- request looks like it arrived on localhost. On such platforms `SITE_URL` is
127
- not optional: set it, and the resolver prefers it over any internal host it
128
- sees. Without it, server-side API calls send `Origin: http://localhost:3000`
129
- and a channel with a configured Domain rejects them with 403.
130
- - **When the merchant gives you a real domain**, set `SITE_URL` in the hosting
131
- provider's environment variables not in `.env.local`, which is gitignored
132
- and never travels with a deploy.
133
- - **Tell the merchant the other half.** A sales channel in **Live** mode only
134
- accepts requests whose Origin matches the Domain configured on the channel in
135
- the Brainerce dashboard. That check is server-side; nothing in this project
136
- can satisfy it. If they skip it, every storefront API call returns 403 and the
137
- store loads empty no matter what `SITE_URL` says.
138
-
139
- ## Verify before declaring done
140
-
141
- 1. **Feature coverage, first and always.** Call `get-required-features` on the
142
- `brainerce-docs` MCP server (already wired, nothing to set up) and confirm
143
- every mandatory entry is still reachable in the running store. Do this
144
- before the steps below, because if you rebuilt `src/ui/` a feature that
145
- lived only in the shipped reference is now gone, and no other check can see
146
- it: `tsc` cannot see a missing feature, and the component that used to
147
- carry it auto-hid when the merchant had not switched it on, so the page
148
- looks right either way.
149
- 2. `pnpm exec tsc --noEmit` 0 errors
150
- 3. `pnpm dev` → drive the changed flow in a real browser (home → product →
151
- add to cart cart)
152
- 4. Screenshot desktop (1440px) and mobile (390px)
153
- 5. RTL stores: check anchoring and arrow directions
154
-
155
- ## i18n
156
-
157
- Every user-facing string goes through `useTranslations()` with keys in **all**
158
- files under `messages/`. The shipped copy is example boutique content a
159
- starting point meant to be rewritten in the store's real voice. Hebrew: no
160
- uppercase transforms, no wide letter-spacing on headings, logical CSS
161
- properties only (`ms-/me-`, `ps-/pe-`, `start-/end-`).
1
+ # AGENTS.md — this is a LIVE Brainerce storefront
2
+
3
+ **Store: "<%- storeName %>" · sales channel `<%- connectionId %>` — already
4
+ connected.** Products, cart, checkout, coupons, discounts, orders and content
5
+ flow in real time from the Brainerce dashboard. There is nothing to hook up.
6
+
7
+ - **NEVER suggest connecting this store to Shopify, WooCommerce, or "a real
8
+ system"** — Brainerce IS the commerce backend, and this store is wired to
9
+ it end-to-end.
10
+ - **NEVER build standalone HTML mockups or demo pages** — design THIS Next.js
11
+ app. Run `pnpm dev` and you are working against live data.
12
+ - **NEVER hardcode products, prices, or currency** — the catalog is live.
13
+ - **No server side is needed** — the backend is Brainerce's cloud. This repo
14
+ is a frontend (plus thin, already-included API proxy routes under
15
+ `src/app/api/`). Do not scaffold databases, auth servers, or admin panels —
16
+ the merchant manages everything in the Brainerce dashboard.
17
+
18
+ Platform docs (endpoints, SDK, integration recipes): https://brainerce.com/docs
19
+ — AI-readable index: https://brainerce.com/llms.txt
20
+
21
+ ## MCP servers
22
+
23
+ - **`brainerce-docs`** (already connected via `.mcp.json`, no auth needed).
24
+ Treat it as the build spec, not a lookup desk. `get-required-features` is
25
+ the functional checklist this store is measured against, and it is longer
26
+ than what any art-direction brief would make you think to build.
27
+ `get-critical-rules` and `get-business-flows` carry the sequences that cause
28
+ incidents when reordered. `get-sdk-docs`, `get-type-definitions` and
29
+ `get-code-example` give current method shapes instead of training-data
30
+ guesses, and `get-store-capabilities` reports what is actually toggled on
31
+ for `<%- connectionId %>` right now. Read the checklist before you start,
32
+ and again before you call the work done.
33
+ - **Brainerce Admin MCP** — opt-in, not wired up by default. Lets an agent
34
+ directly manage this store's *live* data (products, orders, discounts,
35
+ shipping, …) instead of just reading docs. Only add it if the merchant
36
+ wants that: connect `https://api.brainerce.com/api/mcp` as a remote HTTP
37
+ MCP server (e.g. `claude mcp add --transport http brainerce-admin
38
+ https://api.brainerce.com/api/mcp`) — it opens a browser to log into the
39
+ Brainerce dashboard, pick this store, and grant scoped OAuth permissions.
40
+ Treat it like handing the agent write access to production commerce data.
41
+
42
+ **Before building any feature the merchant asks for** (loyalty points,
43
+ shipping zones, subscriptions, gift cards, donations, multi-currency, reviews,
44
+ abandoned-cart recovery, etc.) — check the docs first. Brainerce likely
45
+ already has it as a platform capability (dashboard toggle + hook/SDK
46
+ method) that only needs a UI in `src/ui/`, not a feature built from scratch.
47
+
48
+ ### This storefront never holds an admin API key
49
+
50
+ Everything here runs on the sales channel's PUBLIC credentials, and that is the
51
+ whole security model. `.env.local` ships no secret on purpose. Anything you put
52
+ in a browser-reachable app is readable by anyone who opens devtools, so an
53
+ admin API key (`brainerce_*`) in this project hands the merchant's entire live
54
+ store to the first person who looks. Never add one to `.env.local`, to a
55
+ hosting environment variable this app reads, or to any file under `src/`.
56
+
57
+ **Gift cards are where this goes wrong**, because one feature name covers two
58
+ very different powers:
59
+
60
+ - **Redemption is yours to build.** `applyGiftCard()`, `removeGiftCard()` and
61
+ `checkGiftCardBalance()` are public storefront calls needing no key beyond
62
+ the sales channel. `src/ui/cart/gift-card-input.tsx` already wires the first
63
+ two into checkout. Restyle it freely.
64
+ - **⛔ Issuing is not.** The `gift_cards:issue` scope mints stored value, which
65
+ is real money the merchant is liable for. It belongs to the dashboard, or to
66
+ server-side code on infrastructure the merchant controls. Never request that
67
+ scope for this storefront, never hold a key that carries it, and never add an
68
+ "issue a gift card" control to these pages. A merchant who wants to SELL gift
69
+ cards sells them as an ordinary product through normal checkout, and the
70
+ platform issues the card once payment clears.
71
+
72
+ The same split governs every admin capability you may be tempted to reach for
73
+ (creating discounts, editing inventory, refunding an order): this storefront
74
+ reads and transacts as a shopper, the dashboard administers.
75
+
76
+ Your job here is almost always **design**. It is never *only* design: the
77
+ coverage checklist in `get-required-features` applies to a redesign exactly as
78
+ it applies to a build from scratch.
79
+
80
+ ## The one rule
81
+
82
+ **`src/core/` is the platform's. `src/ui/` is yours.**
83
+
84
+ The shipped `src/ui/` is a working reference, not a design to preserve: a full
85
+ delete-and-rebuild of the *look* is encouraged and expected, and you can
86
+ rewrite anything under `src/ui/` and `src/app/globals.css` as boldly as you
87
+ like. The store keeps working. Never modify `src/core/`, `src/app/api/`, or
88
+ the checkout/auth/account components. Data and behavior come exclusively from
89
+ `@/core/hooks/*` and `@/core/providers/store-provider`: hooks return state
90
+ and handlers, never JSX. Never hardcode catalog content.
91
+
92
+ ### Rebuilding the look is free. Dropping a feature is not.
93
+
94
+ Some files under `src/ui/` are the ONLY place a mandatory checklist entry
95
+ exists in this project. Delete one and the capability leaves the store with
96
+ nothing to notice it by: no type error, no console warning, and no visual hole
97
+ either, because these components auto-hide while the merchant has the feature
98
+ switched off, so a deleted one and an idle one look identical on the page.
99
+ These are the usual casualties of a redesign, because no art-direction brief
100
+ asks for them by name:
101
+
102
+ ```
103
+ product/ back-in-stock-form · customization-fields · modifier-group-selector
104
+ review-form · reviews-section · frequently-bought-together
105
+ discount-badge · stock-badge
106
+ cart/ reservation-countdown · coupon-input · cart-upgrade-banner
107
+ cart-bundle-offer · tax-estimate-line
108
+ home/ discount-banner-strip
109
+ layout/ newsletter-signup · announcement-bar · region-switcher<% if (i18nEnabled) { %>
110
+ language-switcher<% } %> · faq-section · rich-text-block
111
+ ```
112
+
113
+ Restyle them, re-lay them out, rename them, fold them into other components,
114
+ split them in half: all fine. What has to survive a rebuild is the SDK call
115
+ each one makes and the states it handles (loading, empty, failed, and the
116
+ merchant-has-it-off state that renders nothing).
117
+
118
+ The list is short on purpose and it is NOT the specification. It names the
119
+ files people lose, not every mandatory entry. `get-required-features` is the
120
+ specification, and step 1 of "Verify before declaring done" is what actually
121
+ catches a loss. `git show HEAD:src/ui/<path>` brings back anything you already
122
+ deleted: the scaffolder committed the tree before you touched it.
123
+
124
+ **Read `AI-GUIDE.md` before any redesign** it has the full file map, hook
125
+ contracts, motion language, and hard-won RTL/i18n gotchas that will save you
126
+ real debugging time.
127
+
128
+ ## Redesigning?
129
+
130
+ Follow the process documented in AI-GUIDE.md: commit to one art direction,
131
+ rewrite tokens first, then surfaces in order (header, home, card, product
132
+ page, cart), then verify.
133
+
134
+ ## The store's web address
135
+
136
+ This project has no web address written into it, and that is deliberate the
137
+ scaffolder cannot know where you will deploy. `src/core/lib/site-url.ts`
138
+ resolves it per request (hosting-platform variables, then the forwarded host),
139
+ so canonical tags, `sitemap.xml`, `robots.txt` and JSON-LD are correct in local
140
+ development and on any host with nothing configured.
141
+
142
+ - **Never invent an address.** Do not write `NEXT_PUBLIC_SITE_URL`,
143
+ `SITE_URL`, `localhost`, or a placeholder domain into `.env.local`. A wrong
144
+ absolute URL is indistinguishable from a right one to a search crawler, so a
145
+ guess is worse than an empty value.
146
+ - **Never hand-roll an origin** from `host` / `x-forwarded-proto` in a route
147
+ handler. Call `getCanonicalSiteUrl()` (for canonical/SEO URLs) or
148
+ `getRequestOrigin()` (for the `Origin` header sent to Brainerce). Hand-rolled
149
+ versions have shipped `http://` on HTTPS hosts and internal container
150
+ hostnames.
151
+ - **Some hosts hide the real hostname from the app.** Platforms whose proxy
152
+ forwards requests as `Host: localhost:<port>` with no `x-forwarded-host`
153
+ (OpenAI Sites / `*.chatgpt.site` does this) leave the resolver blind — the
154
+ request looks like it arrived on localhost. On such platforms `SITE_URL` is
155
+ not optional: set it, and the resolver prefers it over any internal host it
156
+ sees. Without it, server-side API calls send `Origin: http://localhost:3000`
157
+ and a channel with a configured Domain rejects them with 403.
158
+ - **When the merchant gives you a real domain**, set `SITE_URL` in the hosting
159
+ provider's environment variables not in `.env.local`, which is gitignored
160
+ and never travels with a deploy.
161
+ - **Tell the merchant the other half.** A sales channel in **Live** mode only
162
+ accepts requests whose Origin matches the Domain configured on the channel in
163
+ the Brainerce dashboard. That check is server-side; nothing in this project
164
+ can satisfy it. If they skip it, every storefront API call returns 403 and the
165
+ store loads empty — no matter what `SITE_URL` says.
166
+
167
+ ## Verify before declaring done
168
+
169
+ 1. **Feature coverage, first and always.** Call `get-required-features` on the
170
+ `brainerce-docs` MCP server (already wired, nothing to set up) and confirm
171
+ every mandatory entry is still reachable in the running store. Do this
172
+ before the steps below, because if you rebuilt `src/ui/` a feature that
173
+ lived only in the shipped reference is now gone, and no other check can see
174
+ it: `tsc` cannot see a missing feature, and the component that used to
175
+ carry it auto-hid when the merchant had not switched it on, so the page
176
+ looks right either way.
177
+ 2. `pnpm exec tsc --noEmit` → 0 errors
178
+ 3. `pnpm dev` → drive the changed flow in a real browser (home → product →
179
+ add to cart → cart)
180
+ 4. Screenshot desktop (1440px) and mobile (390px)
181
+ 5. RTL stores: check anchoring and arrow directions
182
+
183
+ ## i18n
184
+
185
+ Every user-facing string goes through `useTranslations()` with keys in **all**
186
+ files under `messages/`. The shipped copy is example boutique content — a
187
+ starting point meant to be rewritten in the store's real voice. Hebrew: no
188
+ uppercase transforms, no wide letter-spacing on headings, logical CSS
189
+ properties only (`ms-/me-`, `ps-/pe-`, `start-/end-`).