@sbuilder/cli 0.8.0 → 0.9.1

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/README.md CHANGED
@@ -11,7 +11,16 @@ Start
11
11
  repo for one of your sites, or an app (same as
12
12
  npm create sbuilder-app)
13
13
 
14
+ Account
15
+ sb login sign in through the browser; stores a credential
16
+ that renews itself
17
+ sb logout sign this machine out and forget that credential
18
+ sb whoami which account (and platform) the CLI acts as
19
+
14
20
  Sites
21
+ sb site new "<description>" [--dir <path>] [--github] [--editor]
22
+ make a site from one sentence, in a repo an AI
23
+ agent builds in (--editor: in the editor instead)
15
24
  sb site init [dir] [--site <id>] [--github]
16
25
  a repo holding one site's pages, synced with
17
26
  GitHub both ways
@@ -24,35 +33,31 @@ Sites
24
33
  to paste into a page file
25
34
  sb site next serve the pages from a Next.js app, rendered by the
26
35
  platform's own renderer
27
- sb mcp the Store Builder MCP server, with this repo's key
28
- sb code pull [--site <id>] [--dir <path>] [--force]
36
+ sb site code pull [--site <id>] [--dir <path>] [--force]
29
37
  mirror a site's Code Dock files into ./code
30
- sb code push [--site <id>] [--dir <path>] [--force] [--dry-run] [--delete]
38
+ sb site code push [--site <id>] [--dir <path>] [--force] [--dry-run] [--delete]
31
39
  send local edits back; refuses a file changed
32
40
  in the Code Dock since your pull unless --force
33
- sb new "<what to build>" make a site from one sentence: opens the editor
34
- and the assistant starts building
35
- sb export next <site-url> [--dir <path>]
36
- a published site as a Next.js repo
37
-
38
- AI assistant
39
- sb agent [--codex] run the editor's AI assistant on THIS machine's
40
- Claude Code login — no API key (--codex: Codex too)
41
+ sb site agents write the AI-agent files into this repo (never overwrites)
42
+ sb site mcp the Store Builder MCP server, with this repo's key
41
43
 
42
44
  Apps (for developers building on the platform)
43
- sb init [name] [--port 3000] scaffold an app that runs, registers, and opens
44
- inside a merchant's admin
45
- sb dev upload an island's code to your DRAFT version
45
+ sb app init [name] [--port 3000] [--with-block]
46
+ scaffold an app that runs, registers, and opens
47
+ inside a merchant's admin; --with-block adds a block
48
+ and its island
49
+ sb app create "<name>" [--site <id>] [--org <id>]
50
+ create the app, a draft version and a sandbox install
51
+ on one of your stores; writes .env and sb.json
52
+ sb app dev upload an island's code to your DRAFT version
46
53
  every time you save it. Reads sb.json; needs
47
54
  sb login (or SB_TOKEN).
48
- sb deploy [--submit] push the version's payload in dependency order.
55
+ sb app deploy [--submit] push the version's payload in dependency order.
49
56
  --submit then sends it for review.
50
57
 
51
- Account
52
- sb login sign in through the browser; stores a credential
53
- that renews itself
54
- sb whoami which account (and platform) the CLI acts as
55
- sb logout sign this machine out and forget that credential
58
+ AI
59
+ sb agent [--codex] run the editor's AI assistant on THIS machine's
60
+ Claude Code login — no API key (--codex: Codex too)
56
61
  ```
57
62
 
58
63
  Node 20 or newer. Written in TypeScript, published compiled — an installed copy
@@ -65,15 +70,14 @@ has no dependencies and nothing to build.
65
70
  - [What this is, and what it is not](#what-this-is-and-what-it-is-not)
66
71
  - [Getting it](#getting-it)
67
72
  - [The five-minute path](#the-five-minute-path)
68
- - [`sb init`](#sb-init--scaffold-an-app-that-runs)
69
- - [`sb.json`](#sbjson--the-file-dev-and-deploy-read)
73
+ - [`sb app init` and `sb app create`](#sb-app-init-and-sb-app-create--an-app-that-runs-and-is-registered)
74
+ - [`sb.json`](#sbjson--the-file-sb-app-dev-and-sb-app-deploy-read)
70
75
  - [`sb login` / `sb logout`](#sb-login--sb-logout--sign-in-through-the-browser)
71
- - [`sb dev`](#sb-dev--save-upload-refresh)
72
- - [`sb deploy`](#sb-deploy--the-whole-payload-in-dependency-order)
73
- - [`sb code`](#sb-code--your-code-dock-files-as-a-folder)
74
- - [`sb new`](#sb-new--a-site-from-one-sentence)
76
+ - [`sb app dev`](#sb-app-dev--save-upload-refresh)
77
+ - [`sb app deploy`](#sb-app-deploy--the-whole-payload-in-dependency-order)
78
+ - [`sb site code`](#sb-site-code--your-code-dock-files-as-a-folder)
75
79
  - [`sb site`](#sb-site--a-site-as-a-repo-you-build-with-ai-synced-with-github)
76
- - [`sb export next`](#sb-export-next--a-published-site-as-a-nextjs-repo)
80
+ - [What changed in 0.9](#what-changed-in-09)
77
81
  - [`sb agent`](#sb-agent--the-editor-assistant-on-your-own-login)
78
82
  - [Environment variables](#environment-variables)
79
83
  - [CI](#ci)
@@ -123,7 +127,7 @@ sb --help
123
127
  Node 20 or newer. The package ships compiled, so an installed copy has no
124
128
  dependencies and nothing to build.
125
129
 
126
- The scaffold `sb init` writes is deliberately the same way: no dependencies, no
130
+ The scaffold `sb app init` writes is deliberately the same way: no dependencies, no
127
131
  build, plain ESM — because that is the code you actually run.
128
132
 
129
133
  > Working on the CLI itself, rather than using it? [CONTRIBUTING.md](./CONTRIBUTING.md).
@@ -132,53 +136,52 @@ build, plain ESM — because that is the code you actually run.
132
136
 
133
137
  ## The five-minute path
134
138
 
135
- The whole loop, start to finish. Steps 2 and 3 are yours — see `/app-docs` — and
136
- everything else is one command.
139
+ The whole loop, start to finish. Registering the app (`sb app create`) needs an
140
+ organization you belong to and a store of yours — see `/app-docs`.
137
141
 
138
142
  ```bash
139
- # 1. A working app on your machine
140
- sb init my-app --port 4000
143
+ # 1. A working app on your machine, with a block merchants can drag onto a page
144
+ sb app init my-app --port 4000 --with-block
141
145
  cd my-app
142
- cp .env.example .env # fill in SB_CLIENT_ID and SB_CLIENT_SECRET
143
- npm start
144
- ```
145
146
 
146
- 2. **Create the app** in your organization, and note the `clientId` /
147
- `clientSecret` it returns. The secret is shown **once**.
148
- 3. **Create a DRAFT version** pointing at your local URLs — embed URL
149
- `http://localhost:4000/embed`, redirect URI
150
- `http://localhost:4000/oauth/callback`. **No tunnel is needed:** a draft
151
- version may point at `http://localhost` and a sandbox install may frame it,
152
- so the entire development loop runs on your own machine. A tunnel is only for
153
- checking the public URLs before you submit.
154
-
155
- ```bash
156
- # 4. Sign in once (prints a code you type in the browser)
147
+ # 2. Sign in once (prints a code you type in the browser)
157
148
  sb login
158
149
 
159
- # 5. Write sb.json with the ids you now have (see below), then:
160
- sb dev # edit an island, save, refresh
150
+ # 3. Create the app, a draft version pointing at localhost, and a sandbox install
151
+ # on one of your stores. Writes .env (the client secret, once) and sb.json.
152
+ sb app create "My app"
153
+ npm start # the app, on http://localhost:4000
154
+
155
+ # 4. Send the block and its island to the draft, then edit the island:
156
+ sb app deploy
157
+ sb app dev # edit an island, save, refresh
161
158
 
162
- # 6. Push the whole payload, and send it for review
163
- sb deploy --submit
159
+ # 5. When it is ready: public https URLs on the version, then
160
+ sb app deploy --submit
164
161
  ```
165
162
 
163
+ **No tunnel is needed:** a draft version may point at `http://localhost` and a
164
+ sandbox install may frame it, so the entire development loop runs on your own
165
+ machine. A tunnel is only for checking the public URLs before you submit.
166
+
166
167
  ---
167
168
 
168
- ## `sb init` — scaffold an app that runs
169
+ ## `sb app init` and `sb app create` — an app that runs, and is registered
169
170
 
170
171
  ```bash
171
- sb init my-app
172
- sb init my-app --port 4000
172
+ sb app init my-app
173
+ sb app init my-app --port 4000
174
+ sb app init my-app --with-block
173
175
  ```
174
176
 
175
177
  Writes a working app into `./my-app` and prints what to do next. It makes **no
176
- network calls at all** — it is a scaffolder, not a registration step. Creating
177
- the app and creating a version are still yours to do.
178
+ network calls at all** — it is a scaffolder; `sb app create` (below) registers
179
+ it. A bare `sb init` on a terminal asks what to start instead; its choice 3 runs
180
+ this flow.
178
181
 
179
182
  ### What it writes
180
183
 
181
- Five files, and nothing else:
184
+ Nine files, and nothing else:
182
185
 
183
186
  | File | What it is |
184
187
  | --- | --- |
@@ -187,10 +190,25 @@ Five files, and nothing else:
187
190
  | `.env.example` | `SB_CLIENT_ID`, `SB_CLIENT_SECRET`, `SB_API`, `SB_REDIRECT_URI` and `PORT` |
188
191
  | `README.md` | The same next steps the command prints, for when the terminal has scrolled |
189
192
  | `.gitignore` | `node_modules` and `.env` |
193
+ | `AGENTS.md`, `CLAUDE.md`, `GEMINI.md` | The rules for an AI coding agent in this repo (never commit `.env`, never submit unasked); `CLAUDE.md` and `GEMINI.md` just import `AGENTS.md` |
194
+ | `.claude/skills/sbuilder-app/SKILL.md` | The dev loop, the `sb.json` keys, the OAuth callback and embed, and the rules the platform enforces on a version. `AGENTS.md` points at it, so every agent reads the same text. There is no MCP config: the MCP server is a site's design tools, and an app repo holds no site key |
195
+
196
+ Without `--with-block` there are deliberately **no blocks, no islands and no app
197
+ data**. Each is a real feature with its own guide, and none is needed to watch an
198
+ app appear inside a merchant's admin for the first time.
199
+
200
+ ### `--with-block` — a block a merchant can drag onto a page
190
201
 
191
- There are deliberately **no blocks, no islands and no app data**. Each is a real
192
- feature with its own guide, and none is needed to watch an app appear inside a
193
- merchant's admin for the first time.
202
+ Three more files:
203
+
204
+ | File | What it is |
205
+ | --- | --- |
206
+ | `blocks.json` | One block, "Hello card": a `flex-block` with a `heading` and a `button`, and a trait to edit the heading. It is exactly the body of `PUT .../blocks` (see `/block-docs`) |
207
+ | `islands/hello-card.js` | The island the block names: it counts clicks on the button. A plain class the page's loader constructs; it registers under `app.<appId>.hello-card` by reading that name off the page, so no id is pasted into it |
208
+ | `sb.json` | What `sb app dev` and `sb app deploy` read, with the three ids **empty** until `sb app create` fills them |
209
+
210
+ The repository's tests run `blocks.json` through the platform's own block
211
+ validator, so what the flag writes is what the server accepts.
194
212
 
195
213
  ### The name
196
214
 
@@ -200,9 +218,9 @@ lower-cased, any run of characters outside `a-z 0-9 . _ -` collapsed to a single
200
218
 
201
219
  | You type | You get |
202
220
  | --- | --- |
203
- | `sb init my-app` | `./my-app` |
204
- | `sb init "My App!"` | `./my-app` |
205
- | `sb init` | `./my-app` |
221
+ | `sb app init my-app` | `./my-app` |
222
+ | `sb app init "My App!"` | `./my-app` |
223
+ | `sb app init` | `./my-app` |
206
224
 
207
225
  ### What it refuses
208
226
 
@@ -215,26 +233,79 @@ refuses the lot and names what clashed:
215
233
  Pick an empty directory, or move those files aside.
216
234
  ```
217
235
 
236
+ The four agent files (`AGENTS.md`, `CLAUDE.md`, `GEMINI.md` and the skill) are the one exception:
237
+ if one is already there it is **kept**, with a note, so a fresh clone that has its own `AGENTS.md`
238
+ still scaffolds. A symbolic link in the way of any file is refused.
239
+
218
240
  A partial scaffold is worse than none, because it leaves a directory that looks
219
241
  initialised and is not. An *existing* directory is otherwise fine — running
220
- `sb init` inside a fresh `git clone` is normal, and refusing it because `.git`
242
+ `sb app init` inside a fresh `git clone` is normal, and refusing it because `.git`
221
243
  exists would refuse the common case.
222
244
 
223
245
  ### Flags
224
246
 
225
247
  | Flag | Default | Effect |
226
248
  | --- | --- | --- |
227
- | `--port <n>` | `3000` | The port baked into `.env.example`, the generated README and every URL the command prints. A value that is not a positive number is refused with `--port must be a number` |
249
+ | `--port <n>` | `3000` | The port baked into `.env.example`, the generated README, every URL the command prints and (with `--with-block`) the draft URLs in `sb.json`. A value that is not a positive number is refused with `--port must be a number` |
250
+ | `--with-block` | off | Also write `blocks.json`, `islands/hello-card.js` and `sb.json` |
251
+
252
+ ### `sb app create "<name>"` — the app, a draft, and a sandbox install
253
+
254
+ ```bash
255
+ sb login
256
+ sb app create "My app"
257
+ sb app create "My app" --site <site-id> --org <org-id>
258
+ ```
259
+
260
+ Run it inside the app folder. With your `sb login` session it:
261
+
262
+ 1. creates the **app** in your organization — the response carries the OAuth client
263
+ secret **once**;
264
+ 2. writes `.env` with `SB_CLIENT_ID` and `SB_CLIENT_SECRET` (mode `0600`, added to
265
+ `.gitignore` when missing) — everything that could refuse that write (a missing
266
+ folder, a symbolic link) is checked **before** the app is created, because nothing
267
+ can recover the secret afterwards;
268
+ 3. creates a **draft version** pointing at `http://localhost:<port>/embed` with
269
+ redirect URI `/oauth/callback` (the addresses already in `sb.json` when it names
270
+ some; scope `products.read`);
271
+ 4. **installs** that draft on one of your stores — the consent a merchant gives; for a
272
+ member of the publishing organization it records a *sandbox* install. The
273
+ authorization code it returns lasts 60 seconds and is not redeemed, so **the app has
274
+ no access token yet**: with `npm start` running, approve the install again ("Install
275
+ on my store" in the developer portal) and the app receives its token at
276
+ `/oauth/callback`; the embedded screen works without one;
277
+ 5. fills `sb.json` (`orgId`, `appId`, `versionId`, `siteId`, `version`), keeping every
278
+ other key, and prints where the app opens: the store's **Apps** screen in the admin
279
+ and the app's page in the developer portal.
280
+
281
+ **The client secret goes to `.env` and nowhere else** — never to the terminal.
282
+ Which organization and store: `--org` and `--site` name them; with neither, the only
283
+ one is taken, and several are asked about on a terminal (anywhere else it refuses,
284
+ listing them, and creates nothing).
285
+
286
+ **It stops where it must, and says where.** A step the server refuses leaves the app
287
+ and the secret in place and names what exists; run it again and it continues from the
288
+ app. If `sb.json` already names an app and a version it creates nothing. The install
289
+ needs a **user session** (`sb login`, or a user token in `SB_TOKEN`) — an API key or a
290
+ deploy key cannot give consent.
291
+
292
+ | Flag | Effect |
293
+ | --- | --- |
294
+ | `--site <id>` | The store to install the draft on (its id or slug) |
295
+ | `--org <id>` | The organization that publishes the app |
296
+ | `--yes` | Accept scopes or addresses in `sb.json` beyond the scaffold's own (loopback URLs, `products.read`). Without it, a terminal is asked and anything else refuses — before creating anything. What will be installed is printed first either way |
297
+ | `--port <n>` | The port the draft's URLs name when `sb.json` has none; `3000` by default |
228
298
 
229
299
  ---
230
300
 
231
- ## `sb.json` — the file `dev` and `deploy` read
301
+ ## `sb.json` — the file `sb app dev` and `sb app deploy` read
232
302
 
233
- Both `sb dev` and `sb deploy` read an `sb.json` from the **current directory**.
303
+ Both `sb app dev` and `sb app deploy` read an `sb.json` from the **current directory**.
234
304
 
235
- **`sb init` does not write it, and it cannot**: three of its five required fields
236
- are ids the platform mints when you create the app and its draft version, which
237
- has not happened yet at `init` time. Write it by hand once you have them:
305
+ **`sb app create` writes it** — three of its five required fields are ids the
306
+ platform mints when the app and its draft version are created, and `sb app init
307
+ --with-block` ships it with those three empty. Without `sb app create`, write it by
308
+ hand once you have the ids:
238
309
 
239
310
  ```json
240
311
  {
@@ -253,26 +324,26 @@ has not happened yet at `init` time. Write it by hand once you have them:
253
324
  | `orgId` | The organization that owns the app |
254
325
  | `appId` | The app |
255
326
  | `versionId` | The **draft** version being edited |
256
- | `island` | The island `sb dev` uploads to |
257
- | `entry` | The file `sb dev` watches, relative to `sb.json` |
327
+ | `island` | The island `sb app dev` uploads to |
328
+ | `entry` | The file `sb app dev` watches, relative to `sb.json` |
258
329
 
259
330
  A missing key is refused by name — `sb.json is missing "versionId".` — and a
260
- missing file is refused with the list of what it needs. `sb deploy` requires all
331
+ missing file is refused with the list of what it needs. `sb app deploy` requires all
261
332
  five even though its own work is described by the optional keys below, so fill
262
333
  them in even if you are only deploying blocks.
263
334
 
264
335
  ### Optional — each one found becomes a deploy step
265
336
 
266
- | Key | Type | What `sb deploy` does with it |
337
+ | Key | Type | What `sb app deploy` does with it |
267
338
  | --- | --- | --- |
268
339
  | `version` | object | `PUT` as the version's fields — `scopes`, `embedUrl`, `redirectUri` and the rest |
269
340
  | `blocks` | path | The block manifest, `PUT` as the body of `.../blocks` |
270
341
  | `islands` | array of `{name, entry}` | Declares every `name`, then uploads every `entry` |
271
342
 
272
- An `sb.json` with only the five required keys is valid: `sb dev` works, and
273
- `sb deploy` finds no steps to run.
343
+ An `sb.json` with only the five required keys is valid: `sb app dev` works, and
344
+ `sb app deploy` finds no steps to run.
274
345
 
275
- `sb code` reads one more optional key from the same file, `siteId`, and nothing
346
+ `sb site code` reads one more optional key from the same file, `siteId`, and nothing
276
347
  else: it does not need the five required keys.
277
348
 
278
349
  A fuller one:
@@ -329,8 +400,8 @@ local and a production sign-in coexist), in
329
400
  only (mode `0600`). `sb login` is a separate signed-in device on your account,
330
401
  listed with your other sessions; signing out everywhere ends it too.
331
402
 
332
- **It renews itself.** When the server refuses the access token, `sb dev`,
333
- `sb deploy` and `sb code` rotate the pair once, save it, and retry the request. Two `sb`
403
+ **It renews itself.** When the server refuses the access token, `sb app dev`,
404
+ `sb app deploy` and `sb site code` rotate the pair once, save it, and retry the request. Two `sb`
334
405
  processes renewing at the same moment take turns through a lock file beside
335
406
  the credentials, and the second one adopts the pair the first one saved — a
336
407
  refresh token presented twice would end the session. If the renewal itself is
@@ -353,10 +424,10 @@ key, or `Not signed in` (exit 1).
353
424
 
354
425
  ---
355
426
 
356
- ## `sb dev` — save, upload, refresh
427
+ ## `sb app dev` — save, upload, refresh
357
428
 
358
429
  ```bash
359
- SB_TOKEN=<your token> sb dev
430
+ SB_TOKEN=<your token> sb app dev
360
431
  ```
361
432
 
362
433
  Watches the `entry` file from `sb.json` and uploads it to the version's `island`
@@ -379,16 +450,16 @@ command removes is the friction of finding the endpoint: you save, it uploads,
379
450
  approval pins a payload, and an island swapped after review is code running on
380
451
  merchants' pages that nobody looked at.
381
452
 
382
- `sb dev` takes no flags. It uploads **one** island — the one named in `sb.json`.
383
- To push several at once, use `sb deploy` with an `islands` array.
453
+ `sb app dev` takes no flags. It uploads **one** island — the one named in `sb.json`.
454
+ To push several at once, use `sb app deploy` with an `islands` array.
384
455
 
385
456
  ---
386
457
 
387
- ## `sb deploy` — the whole payload, in dependency order
458
+ ## `sb app deploy` — the whole payload, in dependency order
388
459
 
389
460
  ```bash
390
- SB_TOKEN=<your token> sb deploy
391
- SB_TOKEN=<your token> sb deploy --submit
461
+ SB_TOKEN=<your token> sb app deploy
462
+ SB_TOKEN=<your token> sb app deploy --submit
392
463
  ```
393
464
 
394
465
  Runs every step your `sb.json` describes, in this order:
@@ -421,14 +492,14 @@ What the command owes you instead is to say where it stopped:
421
492
  Stopped at: island "countdown"
422
493
 
423
494
  This version is in review or already approved, so its code is frozen.
424
- Create a new draft version and point sb dev at that one.
495
+ Create a new draft version and point sb app dev at that one.
425
496
  (server: version has left draft)
426
497
 
427
498
  Already applied: version fields, blocks, island declarations
428
499
 
429
500
  This left the version UNFINISHED, not broken — a draft is allowed to be
430
501
  partway through, and it simply cannot be submitted until the rest lands.
431
- Fix the cause and run sb deploy again; every step is safe to repeat.
502
+ Fix the cause and run sb app deploy again; every step is safe to repeat.
432
503
  ```
433
504
 
434
505
  Every write is idempotent, so resuming is simply running it again.
@@ -454,12 +525,12 @@ earlier, with more room to explain than a status code has.
454
525
 
455
526
  ---
456
527
 
457
- ## `sb code` — your Code Dock files as a folder
528
+ ## `sb site code` — your Code Dock files as a folder
458
529
 
459
530
  ```bash
460
- sb code pull --site <site-id>
531
+ sb site code pull --site <site-id>
461
532
  # edit code/site/css/main.css in your own editor, then
462
- sb code push
533
+ sb site code push
463
534
  ```
464
535
 
465
536
  Mirrors a site's **Code Dock** files — the site-wide and per-page CSS, JavaScript
@@ -483,7 +554,7 @@ keeps its local path, because it is tracked by its id, and its content still syn
483
554
  A Code Dock file with no name pulls as `unnamed-<id>.<ext>` and is
484
555
  tracked by its id.
485
556
 
486
- Symbolic links never lead `sb code` outside the root: a file that is a link, or whose
557
+ Symbolic links never lead `sb site code` outside the root: a file that is a link, or whose
487
558
  folder leads outside the root through one, is named and skipped — pull writes nothing
488
559
  through it, push sends nothing from it — while the other files still sync and the run
489
560
  exits `1`. Two links are refused before anything is sent: a `.sb-code.json` that is a
@@ -492,19 +563,19 @@ to sync through it deliberately.
492
563
 
493
564
  `.sb-code.json` records, per file, the server's id and metadata, its `updatedAt`
494
565
  and a sha256 of the content **as last pulled or pushed**. That is the base both
495
- directions compare against, which is how `sb code` tells your edit from an edit
566
+ directions compare against, which is how `sb site code` tells your edit from an edit
496
567
  made in the Code Dock. **Commit it**: a CI push then judges conflicts against the
497
568
  last pull you committed.
498
569
 
499
570
  ### Pull
500
571
 
501
- `sb code pull` writes every file the server has. It **never overwrites a local
572
+ `sb site code pull` writes every file the server has. It **never overwrites a local
502
573
  edit**:
503
574
 
504
575
  - Your file changed and the server's did not: it is left alone and printed as
505
- `pending` — `sb code push` sends it. Exit `0`.
576
+ `pending` — `sb site code push` sends it. Exit `0`.
506
577
  - Both changed: the file is kept, named, and the run exits `1`.
507
- - `sb code pull --force` overwrites every local edit with the server's version,
578
+ - `sb site code pull --force` overwrites every local edit with the server's version,
508
579
  in both cases.
509
580
  - A file deleted on the server is removed locally only if you never edited it.
510
581
 
@@ -512,7 +583,7 @@ It ends with a summary line: written, pending, kept, removed.
512
583
 
513
584
  ### Push
514
585
 
515
- `sb code push` builds a plan against the manifest:
586
+ `sb site code push` builds a plan against the manifest:
516
587
 
517
588
  | Plan | When | Needs |
518
589
  | --- | --- | --- |
@@ -523,7 +594,7 @@ It ends with a summary line: written, pending, kept, removed.
523
594
  Creates run first, then updates, then deletes. Each update and delete carries the
524
595
  `updatedAt` from your last pull, and **the server compares it inside the write**:
525
596
  a file changed in the Code Dock since then answers `409 code_file_changed`, that
526
- one file is refused ("changed in the Code Dock since your pull; run sb code pull,
597
+ one file is refused ("changed in the Code Dock since your pull; run sb site code pull,
527
598
  or push --force"), the rest of the run continues, and the exit code is `1`.
528
599
 
529
600
  **The manifest is written after every operation**, so a run that stops halfway —
@@ -588,14 +659,14 @@ A `wbk_` key whose manifest shares **no** file with the server's list is refused
588
659
  as belonging to a different site, so a CI key cannot write site A's files onto
589
660
  site B. `--force` overrides it.
590
661
 
591
- ### CI for `sb code`
662
+ ### CI for `sb site code`
592
663
 
593
664
  Create an API key in the merchant's **Settings → API keys** with `codefiles.write`
594
665
  (add `pages.read` if CI creates files in a page folder the manifest does not
595
666
  know yet), and store it as the CI secret `SB_TOKEN`:
596
667
 
597
668
  ```bash
598
- SB_TOKEN="$SB_API_KEY" sb code push
669
+ SB_TOKEN="$SB_API_KEY" sb site code push
599
670
  ```
600
671
 
601
672
  A key without `codefiles.write` is refused by the server and nothing is written.
@@ -612,46 +683,50 @@ file missing locally without `--delete`, is printed and is **not** a failure.
612
683
 
613
684
  ---
614
685
 
615
- ## `sb new` — a site from one sentence
616
-
617
- ```
618
- sb new "a shop selling handmade candles"
619
- ```
620
-
621
- Opens the editor, which creates the site and starts building it. Signed out, it
622
- runs the `sb login` flow first. If `sb agent` is already running it does the work;
623
- if not and Claude Code is installed, `sb new` serves as the agent itself and stays
624
- open until you press Ctrl-C. With neither, or with the bridge switched off, the
625
- platform's assistant builds it on your plan's allowance.
626
-
627
- The link opens only for the account that asked and lasts 15 minutes. Opening it a
628
- second time inside those 15 minutes makes a second site.
629
-
630
- While your `sb agent` is running, every new site you start from `sb new`, the home
631
- page or the dashboard picks "Claude Code (sb agent)", so its first build uses your
632
- Claude Code login. That stays the site's setting: with no `sb agent` running the
633
- assistant on that site stops and says so, rather than falling back to the
634
- platform's key. Keep it running (`sb agent install`) or change the provider in the
635
- assistant's settings.
636
-
637
686
  ## `sb site` — a site as a repo you build with AI, synced with GitHub
638
687
 
639
688
  ```
640
- npm create sbuilder-app # or: sb init — "a new website, built by AI" is choice 1
689
+ sb init # a menu: "a new website, built by AI" is choice 1
690
+ sb site new "a shop selling handmade candles" # the same, from the command line
641
691
  sb site init my-shop --github # a repo for one of your sites, on a private GitHub repo
642
692
  sb site pull # take what was edited in the editor
643
693
  sb site push # save edited page files as DRAFTS
644
694
  sb site publish --all # make pages live (or name files)
645
695
  sb site next # serve the pages from a Next.js app (npm run dev)
646
- sb mcp # the Store Builder MCP server, with this repo's key
647
- ```
696
+ sb site agents # the AI-agent files, for a repo made by an older CLI
697
+ sb site mcp # the Store Builder MCP server, with this repo's key
698
+ ```
699
+
700
+ **`sb site new "<description>"`** creates a site (named from the first words of your
701
+ description), writes the repo below into `./<name>` (`--dir` picks another folder,
702
+ `--github` also makes the private GitHub repo) and — when Claude Code is installed —
703
+ offers to start it in that folder with your description. Signed out, it runs the
704
+ `sb login` flow first. It is exactly what choice 1 of `sb init` does.
705
+
706
+ **`sb site new --editor "<description>"`** builds in the editor instead: it opens the
707
+ editor, which creates the site and starts building it. If `sb agent` is already
708
+ running it does the work; if not and Claude Code is installed, the command serves as
709
+ the agent itself and stays open until you press Ctrl-C. With neither, or with the
710
+ bridge switched off, the platform's assistant builds it on your plan's allowance.
711
+ The link opens only for the account that asked and lasts 15 minutes; opening it a
712
+ second time inside those 15 minutes makes a second site. While your `sb agent` is
713
+ running, every new site you start from here, the home page or the dashboard picks
714
+ "Claude Code (sb agent)"; that stays the site's setting: with no `sb agent` running
715
+ the assistant on that site stops and says so, rather than falling back to the
716
+ platform's key.
717
+
718
+ | Flag | Effect |
719
+ | --- | --- |
720
+ | `--editor` | Build in the editor (the assistant, or your `sb agent`) instead of in a repo |
648
721
 
649
- **Building with AI.** Choice 1 of `sb init` asks you to describe the website, creates
722
+ **Building with AI.** Choice 1 of `sb init` (and `sb site new`) takes your description, creates
650
723
  the site, writes the repo below and — when Claude Code is installed — starts it in
651
724
  that folder with your description, so building starts right there. Any agent works:
652
- the repo carries `.mcp.json`, `.cursor/mcp.json` and `.vscode/mcp.json`, so Claude
653
- Code, Cursor and VS Code see the Store Builder tools as soon as the folder is opened
654
- (approve the `sbuilder` server once), and `AGENTS.md` (imported by `CLAUDE.md`) tells
725
+ the repo carries `.mcp.json`, `.cursor/mcp.json`, `.vscode/mcp.json`, `.gemini/settings.json` and
726
+ `.codex/config.toml`, so Claude
727
+ Code, Codex, Cursor, Gemini CLI and VS Code see the Store Builder tools as soon as the folder
728
+ is opened (approve the `sbuilder` server once; **Codex: trust the folder once**, or it does not
729
+ read `.codex/config.toml`), and `AGENTS.md` (imported by `CLAUDE.md` and `GEMINI.md`) tells
655
730
  the agent how to work: native elements first, look at every section on desktop and
656
731
  mobile, ask for real facts, pull the result into the repo, **never publish unasked**.
657
732
  The agent edits the site's drafts; you review what it did as a git diff.
@@ -662,17 +737,26 @@ takes `--site <id>`), and writes:
662
737
  | Path | What it is |
663
738
  | --- | --- |
664
739
  | `design/pages/*.page.tsx` | One page's draft as source (see *Page files* below) |
665
- | `code/` | The site's Code Dock files (`sb code pull --dir code`) |
740
+ | `code/` | The site's Code Dock files (`sb site code pull --dir code`) |
666
741
  | `.sb-site.json` | What was last synced — commit it |
667
742
  | `.env` | An API key minted for this repo, mode `0600`, git-ignored |
668
- | `.mcp.json`, `.cursor/mcp.json`, `.vscode/mcp.json` | The MCP server, started as `sb mcp` |
669
- | `AGENTS.md`, `CLAUDE.md` | How an AI agent works in this repo |
743
+ | `.mcp.json`, `.cursor/mcp.json`, `.vscode/mcp.json`, `.gemini/settings.json`, `.codex/config.toml` | The MCP server, started as `sb site mcp`, for Claude Code, Cursor, VS Code, Gemini CLI and Codex |
744
+ | `AGENTS.md`, `CLAUDE.md`, `GEMINI.md` | How an AI agent works in this repo; the other two import `AGENTS.md` |
745
+ | `.claude/skills/sbuilder-page/SKILL.md` | The page syntax, the section-building loop with the tools, app-block rules and what pull / push / publish do — `AGENTS.md` points at it, so every agent reads the same text |
670
746
  | `.github/workflows/sbuilder.yml` | The GitHub half of the sync |
671
747
 
748
+ None of the agent files above is overwritten. One that is already there is kept — silently when it
749
+ is what init would write, otherwise with a note saying what it lacks and the exact text to add.
750
+ `sb site agents` writes just these files into a repo made by an older version of the CLI, with the same rule.
751
+ A symbolic link in the way of any file init writes (`.env`, `.github`, …) is refused before the
752
+ key is minted (an agent file behind a link is skipped with a note instead), and an existing
753
+ `.env` is never replaced. A folder's own `.gitignore` is kept — init only adds `node_modules` and
754
+ `.env` to it — and so is its own `README.md`.
755
+
672
756
  The key is named `AI agent · <folder>` and carries every content permission your
673
757
  account may delegate — never members, roles, site settings or export. Revoke it in
674
758
  Settings -> API keys. If it cannot be minted, init says so and carries on. Inside the
675
- repo, `sb site`, `sb code` and `sb mcp` read `.env`; a variable already set in your
759
+ repo, `sb site`, `sb site code` and `sb site mcp` read `.env`; a variable already set in your
676
760
  shell wins. `--github` then runs `git init`, the first commit, `gh repo create
677
761
  --private --push` and `gh secret set SB_TOKEN` (the key goes in on stdin, never on a
678
762
  command line) — the workflow is live with nothing left to paste.
@@ -734,27 +818,24 @@ or deleted from files: create one in the editor (or let the agent), then pull; a
734
818
  deleted on the platform keeps its file and is named. With an API key it uses
735
819
  `/api/v1/pages/{id}/document` and needs no `--site`.
736
820
 
737
- ## `sb export next` — a published site as a Next.js repo
738
-
739
- ```
740
- sb export next https://your-shop.example --dir my-shop
741
- ```
821
+ ## What changed in 0.9
742
822
 
743
- Reads the site's `sitemap.xml`, fetches every page it lists and writes a Next.js
744
- repo (into `./<host>` without `--dir`; the folder must be empty or new). Each
745
- page is kept exactly as the site published it, in `site/`, and served by a static
746
- route in `app/`. Nothing is re-rendered.
823
+ The commands moved into groups. **The old names still work in 0.9** and print one
824
+ line on stderr naming the new form (stdout is untouched — `sb mcp` speaks the MCP
825
+ protocol over it, and repos made by 0.8 still start it):
747
826
 
748
- Everything the export does not hold — cart, checkout, forms, images, the
749
- published-page runtime under `/_wb/`, and any page missing from the sitemap — is
750
- forwarded to the live site by a fallback rewrite in `next.config.mjs`
751
- (`SITE_ORIGIN` overrides the address). The browser sees one origin, so shopper
752
- sign-in keeps working on the new host.
827
+ | 0.8 | 0.9 |
828
+ | --- | --- |
829
+ | `sb dev` | `sb app dev` |
830
+ | `sb deploy` | `sb app deploy` |
831
+ | `sb code …` | `sb site code …` |
832
+ | `sb new "…"` | `sb site new --editor "…"` |
833
+ | `sb mcp` | `sb site mcp` |
834
+ | `sb init <name>` | `sb app init <name>` |
753
835
 
754
- It is a snapshot: prices and stock shown in the HTML are as of the export, so
755
- run it again after you publish. A page the site does not answer with HTML, or
756
- whose path starts with a character Next.js reserves for folders (`_`, `(`, `[`,
757
- `@`), is skipped and named in the output.
836
+ `sb export next` was **removed**: `sb site next` makes a Next.js app rendered by the
837
+ platform's own renderer, which a snapshot of published HTML never was. `sb export …`
838
+ now exits `1` and says so.
758
839
 
759
840
  ## `sb agent` — the editor assistant on your own login
760
841
 
@@ -816,11 +897,11 @@ A user access token expires, so it is the wrong credential for a pipeline. Use a
816
897
  1. In the Developer portal, open your organization and go to **Deploy keys**
817
898
  (an owner or admin can do this), then create one. The secret starts with
818
899
  `sbdk_` and is shown **once**.
819
- 2. Store it as the CI secret `SB_TOKEN`. `sb dev` and `sb deploy` accept it
820
- exactly like a pasted token. (`sb code` does not: see its own CI recipe.)
900
+ 2. Store it as the CI secret `SB_TOKEN`. `sb app dev` and `sb app deploy` accept it
901
+ exactly like a pasted token. (`sb site code` does not: see its own CI recipe.)
821
902
 
822
903
  ```bash
823
- SB_TOKEN="$SB_DEPLOY_KEY" sb deploy
904
+ SB_TOKEN="$SB_DEPLOY_KEY" sb app deploy
824
905
  ```
825
906
 
826
907
  A deploy key does not expire and belongs to the organization, not to the person
@@ -840,27 +921,27 @@ Three are read by the CLI itself:
840
921
 
841
922
  | Variable | Required by | Default |
842
923
  | --- | --- | --- |
843
- | `SB_TOKEN` | `sb dev`, `sb deploy`, `sb code` — optional | none — the `sb login` credential is used; with neither, each stops and names `sb login` |
844
- | `SB_API` | every command but `sb init` | `https://api.sbuilder.io.vn` — set `http://localhost:8080` for a local platform |
924
+ | `SB_TOKEN` | `sb app dev`, `sb app deploy`, `sb app create`, `sb site code` — optional | none — the `sb login` credential is used; with neither, each stops and names `sb login` |
925
+ | `SB_API` | every command but `sb app init` | `https://api.sbuilder.io.vn` — set `http://localhost:8080` for a local platform |
845
926
  | `SB_NO_BROWSER` | `sb login` | unset — set it to stop `sb login` opening the `/device` page (CI and non-terminals never open it) |
846
927
  | `SB_STOREFRONT` | the `sb site next` app | the live store's address (`sb site init` writes it into `.env`) — where `/_wb/*` and paths with no page file are forwarded |
847
928
 
848
- `SB_TOKEN` **overrides** the stored `sb login` credential when set. For `sb dev`
849
- and `sb deploy` it is a token for the **organization that owns the app** — the
929
+ `SB_TOKEN` **overrides** the stored `sb login` credential when set. For `sb app dev`
930
+ and `sb app deploy` it is a token for the **organization that owns the app** — the
850
931
  same user access token you would put in an `Authorization: Bearer` header against
851
932
  the org-scoped routes. It is **not** a `wba_` app token; those belong to an
852
- install, and an install cannot edit the app it is an install of. For `sb code` it
933
+ install, and an install cannot edit the app it is an install of. For `sb site code` it
853
934
  is a user token with access to the site, or a merchant `wbk_` API key (see
854
- [`sb code`](#sb-code--your-code-dock-files-as-a-folder)).
935
+ [`sb site code`](#sb-site-code--your-code-dock-files-as-a-folder)).
855
936
 
856
937
  A pasted token cannot renew itself, and the CLI never tries to refresh it. When
857
- the server refuses a pasted token, `sb dev` and `sb deploy` say
938
+ the server refuses a pasted token, `sb app dev` and `sb app deploy` say
858
939
  `SB_TOKEN was refused: it has expired or been revoked` and point you at
859
- `sb login`. `sb code` says
940
+ `sb login`. `sb site code` says
860
941
  ``Not signed in, or the token was refused (expired or revoked). Run `sb login`, or set SB_TOKEN to an API key (wbk_…) with codefiles.read / codefiles.write from Settings -> API keys.``
861
- instead, and never suggests a deploy key, because `sb code` refuses one.
942
+ instead, and never suggests a deploy key, because `sb site code` refuses one.
862
943
 
863
- Three more are read by the app `sb init` writes, from its own `.env`:
944
+ Three more are read by the app `sb app init` writes, from its own `.env`:
864
945
 
865
946
  | Variable | Read by | What it is |
866
947
  | --- | --- | --- |
@@ -878,9 +959,9 @@ Every command exits `0` on success and `1` on a refusal it can explain. Anything
878
959
  else is a bug in the tool and gets a stack trace, because a scaffolder that
879
960
  swallows its own failures is one nobody can report.
880
961
 
881
- `sb dev` and `sb deploy` translate the server codes below rather than passing
882
- them through verbatim. `sb code` words its own refusals: the refused-token one
883
- is above, and the [`sb code`](#sb-code--your-code-dock-files-as-a-folder)
962
+ `sb app dev` and `sb app deploy` translate the server codes below rather than passing
963
+ them through verbatim. `sb site code` words its own refusals: the refused-token one
964
+ is above, and the [`sb site code`](#sb-site-code--your-code-dock-files-as-a-folder)
884
965
  section describes the command.
885
966
 
886
967
  | Server code | What `sb` says instead |
@@ -902,15 +983,16 @@ shrug.
902
983
 
903
984
  Stated so you can plan around it rather than discover it.
904
985
 
905
- - **It does not create the app, the version, or the install.** `sb init` makes no
906
- network calls. Those steps are yours, by hand or by your own script; the CLI
907
- starts being useful once those ids exist.
908
- - **It does not write `sb.json`**, for the same reason.
986
+ - **`sb app init` makes no network calls.** Registering the app is `sb app create`,
987
+ which makes a *draft* and a *sandbox* install on your own store — nothing is
988
+ submitted for review or made public, and it never creates an organization.
989
+ - **It never prints the client secret.** It goes to `.env` (mode `0600`) and nowhere
990
+ else; lose it and rotate it in the developer portal.
909
991
  - **It never asks for a password.** `sb login` signs in through the browser,
910
992
  and the only thing it stores is the credential file described above.
911
- - **`sb dev` is not hot reload**, and no future version of it can be while an
993
+ - **`sb app dev` is not hot reload**, and no future version of it can be while an
912
994
  island's code is served from the platform's object store.
913
- - **`sb deploy` is not atomic**, deliberately.
995
+ - **`sb app deploy` is not atomic**, deliberately.
914
996
 
915
997
  ---
916
998
 
@@ -918,18 +1000,19 @@ Stated so you can plan around it rather than discover it.
918
1000
 
919
1001
  | Symptom | Cause | Fix |
920
1002
  | --- | --- | --- |
921
- | `Not signed in. Run sb login …` | `dev`/`deploy` have no credential | `sb login`, or set `SB_TOKEN` |
1003
+ | `Not signed in. Run sb login …` | `sb app dev` / `sb app deploy` have no credential | `sb login`, or set `SB_TOKEN` |
922
1004
  | `Your sb login has expired or was revoked.` | The stored session ended (signed out everywhere, or it lapsed) | `sb login` again |
923
1005
  | `SB_TOKEN was refused: …` | The pasted token expired or was revoked | `sb login`, or a fresh token |
924
- | `Not signed in, or the token was refused …` | `sb code` has no credential, the pasted `SB_TOKEN` was refused, or the server still answered 401 after renewing your `sb login` | `sb login`, or set `SB_TOKEN` to a `wbk_` API key with `codefiles.read` / `codefiles.write` from Settings → API keys |
1006
+ | `Not signed in, or the token was refused …` | `sb site code` has no credential, the pasted `SB_TOKEN` was refused, or the server still answered 401 after renewing your `sb login` | `sb login`, or set `SB_TOKEN` to a `wbk_` API key with `codefiles.read` / `codefiles.write` from Settings → API keys |
925
1007
  | `No sb.json here.` | Run from the wrong directory | `cd` to the folder holding `sb.json` |
1008
+ | `sb.json is missing "orgId". It is empty until sb app create fills it in.` | The scaffold's ids are still empty | `sb app create "<name>"` |
926
1009
  | `sb.json is missing "versionId".` | A required key is absent or empty | Add all five required keys |
927
1010
  | `unknown command: …` | Typo, or a stale `dist/` | `npm run build --workspace cli` |
928
1011
  | `--port must be a number` | `--port` got a non-positive or non-numeric value | Pass a positive integer |
929
1012
  | Uploads refused with `not_draft` | The version left draft; approval pins its payload | Create a new draft version and point `sb.json` at it |
930
- | Uploads refused with `island_not_found` | The version does not declare that island | Declare it first — `sb deploy` with an `islands` array does this in the right order |
931
- | `--submit` refused for loopback URLs | `version.embedUrl` / `version.redirectUri` still point at localhost | Set public `https` URLs, `sb deploy` again, then submit |
932
- | The island changed and the page did not | `sb dev` is not hot reload | Refresh the page |
1013
+ | Uploads refused with `island_not_found` | The version does not declare that island | Declare it first — `sb app deploy` with an `islands` array does this in the right order |
1014
+ | `--submit` refused for loopback URLs | `version.embedUrl` / `version.redirectUri` still point at localhost | Set public `https` URLs, `sb app deploy` again, then submit |
1015
+ | The island changed and the page did not | `sb app dev` is not hot reload | Refresh the page |
933
1016
  | `sb` reports a flag this page does not list | You are running an older `dist/` | Rebuild |
934
1017
 
935
1018
  ---