@sbuilder/cli 0.8.0 → 0.9.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.
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,30 @@ 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 mcp the Store Builder MCP server, with this repo's key
41
42
 
42
43
  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
44
+ sb app init [name] [--port 3000] [--with-block]
45
+ scaffold an app that runs, registers, and opens
46
+ inside a merchant's admin; --with-block adds a block
47
+ and its island
48
+ sb app create "<name>" [--site <id>] [--org <id>]
49
+ create the app, a draft version and a sandbox install
50
+ on one of your stores; writes .env and sb.json
51
+ sb app dev upload an island's code to your DRAFT version
46
52
  every time you save it. Reads sb.json; needs
47
53
  sb login (or SB_TOKEN).
48
- sb deploy [--submit] push the version's payload in dependency order.
54
+ sb app deploy [--submit] push the version's payload in dependency order.
49
55
  --submit then sends it for review.
50
56
 
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
57
+ AI
58
+ sb agent [--codex] run the editor's AI assistant on THIS machine's
59
+ Claude Code login — no API key (--codex: Codex too)
56
60
  ```
57
61
 
58
62
  Node 20 or newer. Written in TypeScript, published compiled — an installed copy
@@ -65,15 +69,14 @@ has no dependencies and nothing to build.
65
69
  - [What this is, and what it is not](#what-this-is-and-what-it-is-not)
66
70
  - [Getting it](#getting-it)
67
71
  - [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)
72
+ - [`sb app init` and `sb app create`](#sb-app-init-and-sb-app-create--an-app-that-runs-and-is-registered)
73
+ - [`sb.json`](#sbjson--the-file-sb-app-dev-and-sb-app-deploy-read)
70
74
  - [`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)
75
+ - [`sb app dev`](#sb-app-dev--save-upload-refresh)
76
+ - [`sb app deploy`](#sb-app-deploy--the-whole-payload-in-dependency-order)
77
+ - [`sb site code`](#sb-site-code--your-code-dock-files-as-a-folder)
75
78
  - [`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)
79
+ - [What changed in 0.9](#what-changed-in-09)
77
80
  - [`sb agent`](#sb-agent--the-editor-assistant-on-your-own-login)
78
81
  - [Environment variables](#environment-variables)
79
82
  - [CI](#ci)
@@ -123,7 +126,7 @@ sb --help
123
126
  Node 20 or newer. The package ships compiled, so an installed copy has no
124
127
  dependencies and nothing to build.
125
128
 
126
- The scaffold `sb init` writes is deliberately the same way: no dependencies, no
129
+ The scaffold `sb app init` writes is deliberately the same way: no dependencies, no
127
130
  build, plain ESM — because that is the code you actually run.
128
131
 
129
132
  > Working on the CLI itself, rather than using it? [CONTRIBUTING.md](./CONTRIBUTING.md).
@@ -132,49 +135,48 @@ build, plain ESM — because that is the code you actually run.
132
135
 
133
136
  ## The five-minute path
134
137
 
135
- The whole loop, start to finish. Steps 2 and 3 are yours — see `/app-docs` — and
136
- everything else is one command.
138
+ The whole loop, start to finish. Registering the app (`sb app create`) needs an
139
+ organization you belong to and a store of yours — see `/app-docs`.
137
140
 
138
141
  ```bash
139
- # 1. A working app on your machine
140
- sb init my-app --port 4000
142
+ # 1. A working app on your machine, with a block merchants can drag onto a page
143
+ sb app init my-app --port 4000 --with-block
141
144
  cd my-app
142
- cp .env.example .env # fill in SB_CLIENT_ID and SB_CLIENT_SECRET
143
- npm start
144
- ```
145
-
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
145
 
155
- ```bash
156
- # 4. Sign in once (prints a code you type in the browser)
146
+ # 2. Sign in once (prints a code you type in the browser)
157
147
  sb login
158
148
 
159
- # 5. Write sb.json with the ids you now have (see below), then:
160
- sb dev # edit an island, save, refresh
149
+ # 3. Create the app, a draft version pointing at localhost, and a sandbox install
150
+ # on one of your stores. Writes .env (the client secret, once) and sb.json.
151
+ sb app create "My app"
152
+ npm start # the app, on http://localhost:4000
161
153
 
162
- # 6. Push the whole payload, and send it for review
163
- sb deploy --submit
154
+ # 4. Send the block and its island to the draft, then edit the island:
155
+ sb app deploy
156
+ sb app dev # edit an island, save, refresh
157
+
158
+ # 5. When it is ready: public https URLs on the version, then
159
+ sb app deploy --submit
164
160
  ```
165
161
 
162
+ **No tunnel is needed:** a draft version may point at `http://localhost` and a
163
+ sandbox install may frame it, so the entire development loop runs on your own
164
+ machine. A tunnel is only for checking the public URLs before you submit.
165
+
166
166
  ---
167
167
 
168
- ## `sb init` — scaffold an app that runs
168
+ ## `sb app init` and `sb app create` — an app that runs, and is registered
169
169
 
170
170
  ```bash
171
- sb init my-app
172
- sb init my-app --port 4000
171
+ sb app init my-app
172
+ sb app init my-app --port 4000
173
+ sb app init my-app --with-block
173
174
  ```
174
175
 
175
176
  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.
177
+ network calls at all** — it is a scaffolder; `sb app create` (below) registers
178
+ it. A bare `sb init` on a terminal asks what to start instead; its choice 3 runs
179
+ this flow.
178
180
 
179
181
  ### What it writes
180
182
 
@@ -188,9 +190,22 @@ Five files, and nothing else:
188
190
  | `README.md` | The same next steps the command prints, for when the terminal has scrolled |
189
191
  | `.gitignore` | `node_modules` and `.env` |
190
192
 
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.
193
+ Without `--with-block` there are deliberately **no blocks, no islands and no app
194
+ data**. Each is a real feature with its own guide, and none is needed to watch an
195
+ app appear inside a merchant's admin for the first time.
196
+
197
+ ### `--with-block` — a block a merchant can drag onto a page
198
+
199
+ Three more files:
200
+
201
+ | File | What it is |
202
+ | --- | --- |
203
+ | `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`) |
204
+ | `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 |
205
+ | `sb.json` | What `sb app dev` and `sb app deploy` read, with the three ids **empty** until `sb app create` fills them |
206
+
207
+ The repository's tests run `blocks.json` through the platform's own block
208
+ validator, so what the flag writes is what the server accepts.
194
209
 
195
210
  ### The name
196
211
 
@@ -200,9 +215,9 @@ lower-cased, any run of characters outside `a-z 0-9 . _ -` collapsed to a single
200
215
 
201
216
  | You type | You get |
202
217
  | --- | --- |
203
- | `sb init my-app` | `./my-app` |
204
- | `sb init "My App!"` | `./my-app` |
205
- | `sb init` | `./my-app` |
218
+ | `sb app init my-app` | `./my-app` |
219
+ | `sb app init "My App!"` | `./my-app` |
220
+ | `sb app init` | `./my-app` |
206
221
 
207
222
  ### What it refuses
208
223
 
@@ -217,24 +232,73 @@ Pick an empty directory, or move those files aside.
217
232
 
218
233
  A partial scaffold is worse than none, because it leaves a directory that looks
219
234
  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`
235
+ `sb app init` inside a fresh `git clone` is normal, and refusing it because `.git`
221
236
  exists would refuse the common case.
222
237
 
223
238
  ### Flags
224
239
 
225
240
  | Flag | Default | Effect |
226
241
  | --- | --- | --- |
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` |
242
+ | `--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` |
243
+ | `--with-block` | off | Also write `blocks.json`, `islands/hello-card.js` and `sb.json` |
244
+
245
+ ### `sb app create "<name>"` — the app, a draft, and a sandbox install
246
+
247
+ ```bash
248
+ sb login
249
+ sb app create "My app"
250
+ sb app create "My app" --site <site-id> --org <org-id>
251
+ ```
252
+
253
+ Run it inside the app folder. With your `sb login` session it:
254
+
255
+ 1. creates the **app** in your organization — the response carries the OAuth client
256
+ secret **once**;
257
+ 2. writes `.env` with `SB_CLIENT_ID` and `SB_CLIENT_SECRET` (mode `0600`, added to
258
+ `.gitignore` when missing) — everything that could refuse that write (a missing
259
+ folder, a symbolic link) is checked **before** the app is created, because nothing
260
+ can recover the secret afterwards;
261
+ 3. creates a **draft version** pointing at `http://localhost:<port>/embed` with
262
+ redirect URI `/oauth/callback` (the addresses already in `sb.json` when it names
263
+ some; scope `products.read`);
264
+ 4. **installs** that draft on one of your stores — the consent a merchant gives; for a
265
+ member of the publishing organization it records a *sandbox* install. The
266
+ authorization code it returns lasts 60 seconds and is not redeemed, so **the app has
267
+ no access token yet**: with `npm start` running, approve the install again ("Install
268
+ on my store" in the developer portal) and the app receives its token at
269
+ `/oauth/callback`; the embedded screen works without one;
270
+ 5. fills `sb.json` (`orgId`, `appId`, `versionId`, `siteId`, `version`), keeping every
271
+ other key, and prints where the app opens: the store's **Apps** screen in the admin
272
+ and the app's page in the developer portal.
273
+
274
+ **The client secret goes to `.env` and nowhere else** — never to the terminal.
275
+ Which organization and store: `--org` and `--site` name them; with neither, the only
276
+ one is taken, and several are asked about on a terminal (anywhere else it refuses,
277
+ listing them, and creates nothing).
278
+
279
+ **It stops where it must, and says where.** A step the server refuses leaves the app
280
+ and the secret in place and names what exists; run it again and it continues from the
281
+ app. If `sb.json` already names an app and a version it creates nothing. The install
282
+ needs a **user session** (`sb login`, or a user token in `SB_TOKEN`) — an API key or a
283
+ deploy key cannot give consent.
284
+
285
+ | Flag | Effect |
286
+ | --- | --- |
287
+ | `--site <id>` | The store to install the draft on (its id or slug) |
288
+ | `--org <id>` | The organization that publishes the app |
289
+ | `--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 |
290
+ | `--port <n>` | The port the draft's URLs name when `sb.json` has none; `3000` by default |
228
291
 
229
292
  ---
230
293
 
231
- ## `sb.json` — the file `dev` and `deploy` read
294
+ ## `sb.json` — the file `sb app dev` and `sb app deploy` read
232
295
 
233
- Both `sb dev` and `sb deploy` read an `sb.json` from the **current directory**.
296
+ Both `sb app dev` and `sb app deploy` read an `sb.json` from the **current directory**.
234
297
 
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:
298
+ **`sb app create` writes it** — three of its five required fields are ids the
299
+ platform mints when the app and its draft version are created, and `sb app init
300
+ --with-block` ships it with those three empty. Without `sb app create`, write it by
301
+ hand once you have the ids:
238
302
 
239
303
  ```json
240
304
  {
@@ -253,26 +317,26 @@ has not happened yet at `init` time. Write it by hand once you have them:
253
317
  | `orgId` | The organization that owns the app |
254
318
  | `appId` | The app |
255
319
  | `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` |
320
+ | `island` | The island `sb app dev` uploads to |
321
+ | `entry` | The file `sb app dev` watches, relative to `sb.json` |
258
322
 
259
323
  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
324
+ missing file is refused with the list of what it needs. `sb app deploy` requires all
261
325
  five even though its own work is described by the optional keys below, so fill
262
326
  them in even if you are only deploying blocks.
263
327
 
264
328
  ### Optional — each one found becomes a deploy step
265
329
 
266
- | Key | Type | What `sb deploy` does with it |
330
+ | Key | Type | What `sb app deploy` does with it |
267
331
  | --- | --- | --- |
268
332
  | `version` | object | `PUT` as the version's fields — `scopes`, `embedUrl`, `redirectUri` and the rest |
269
333
  | `blocks` | path | The block manifest, `PUT` as the body of `.../blocks` |
270
334
  | `islands` | array of `{name, entry}` | Declares every `name`, then uploads every `entry` |
271
335
 
272
- An `sb.json` with only the five required keys is valid: `sb dev` works, and
273
- `sb deploy` finds no steps to run.
336
+ An `sb.json` with only the five required keys is valid: `sb app dev` works, and
337
+ `sb app deploy` finds no steps to run.
274
338
 
275
- `sb code` reads one more optional key from the same file, `siteId`, and nothing
339
+ `sb site code` reads one more optional key from the same file, `siteId`, and nothing
276
340
  else: it does not need the five required keys.
277
341
 
278
342
  A fuller one:
@@ -329,8 +393,8 @@ local and a production sign-in coexist), in
329
393
  only (mode `0600`). `sb login` is a separate signed-in device on your account,
330
394
  listed with your other sessions; signing out everywhere ends it too.
331
395
 
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`
396
+ **It renews itself.** When the server refuses the access token, `sb app dev`,
397
+ `sb app deploy` and `sb site code` rotate the pair once, save it, and retry the request. Two `sb`
334
398
  processes renewing at the same moment take turns through a lock file beside
335
399
  the credentials, and the second one adopts the pair the first one saved — a
336
400
  refresh token presented twice would end the session. If the renewal itself is
@@ -353,10 +417,10 @@ key, or `Not signed in` (exit 1).
353
417
 
354
418
  ---
355
419
 
356
- ## `sb dev` — save, upload, refresh
420
+ ## `sb app dev` — save, upload, refresh
357
421
 
358
422
  ```bash
359
- SB_TOKEN=<your token> sb dev
423
+ SB_TOKEN=<your token> sb app dev
360
424
  ```
361
425
 
362
426
  Watches the `entry` file from `sb.json` and uploads it to the version's `island`
@@ -379,16 +443,16 @@ command removes is the friction of finding the endpoint: you save, it uploads,
379
443
  approval pins a payload, and an island swapped after review is code running on
380
444
  merchants' pages that nobody looked at.
381
445
 
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.
446
+ `sb app dev` takes no flags. It uploads **one** island — the one named in `sb.json`.
447
+ To push several at once, use `sb app deploy` with an `islands` array.
384
448
 
385
449
  ---
386
450
 
387
- ## `sb deploy` — the whole payload, in dependency order
451
+ ## `sb app deploy` — the whole payload, in dependency order
388
452
 
389
453
  ```bash
390
- SB_TOKEN=<your token> sb deploy
391
- SB_TOKEN=<your token> sb deploy --submit
454
+ SB_TOKEN=<your token> sb app deploy
455
+ SB_TOKEN=<your token> sb app deploy --submit
392
456
  ```
393
457
 
394
458
  Runs every step your `sb.json` describes, in this order:
@@ -421,14 +485,14 @@ What the command owes you instead is to say where it stopped:
421
485
  Stopped at: island "countdown"
422
486
 
423
487
  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.
488
+ Create a new draft version and point sb app dev at that one.
425
489
  (server: version has left draft)
426
490
 
427
491
  Already applied: version fields, blocks, island declarations
428
492
 
429
493
  This left the version UNFINISHED, not broken — a draft is allowed to be
430
494
  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.
495
+ Fix the cause and run sb app deploy again; every step is safe to repeat.
432
496
  ```
433
497
 
434
498
  Every write is idempotent, so resuming is simply running it again.
@@ -454,12 +518,12 @@ earlier, with more room to explain than a status code has.
454
518
 
455
519
  ---
456
520
 
457
- ## `sb code` — your Code Dock files as a folder
521
+ ## `sb site code` — your Code Dock files as a folder
458
522
 
459
523
  ```bash
460
- sb code pull --site <site-id>
524
+ sb site code pull --site <site-id>
461
525
  # edit code/site/css/main.css in your own editor, then
462
- sb code push
526
+ sb site code push
463
527
  ```
464
528
 
465
529
  Mirrors a site's **Code Dock** files — the site-wide and per-page CSS, JavaScript
@@ -483,7 +547,7 @@ keeps its local path, because it is tracked by its id, and its content still syn
483
547
  A Code Dock file with no name pulls as `unnamed-<id>.<ext>` and is
484
548
  tracked by its id.
485
549
 
486
- Symbolic links never lead `sb code` outside the root: a file that is a link, or whose
550
+ Symbolic links never lead `sb site code` outside the root: a file that is a link, or whose
487
551
  folder leads outside the root through one, is named and skipped — pull writes nothing
488
552
  through it, push sends nothing from it — while the other files still sync and the run
489
553
  exits `1`. Two links are refused before anything is sent: a `.sb-code.json` that is a
@@ -492,19 +556,19 @@ to sync through it deliberately.
492
556
 
493
557
  `.sb-code.json` records, per file, the server's id and metadata, its `updatedAt`
494
558
  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
559
+ directions compare against, which is how `sb site code` tells your edit from an edit
496
560
  made in the Code Dock. **Commit it**: a CI push then judges conflicts against the
497
561
  last pull you committed.
498
562
 
499
563
  ### Pull
500
564
 
501
- `sb code pull` writes every file the server has. It **never overwrites a local
565
+ `sb site code pull` writes every file the server has. It **never overwrites a local
502
566
  edit**:
503
567
 
504
568
  - 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`.
569
+ `pending` — `sb site code push` sends it. Exit `0`.
506
570
  - 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,
571
+ - `sb site code pull --force` overwrites every local edit with the server's version,
508
572
  in both cases.
509
573
  - A file deleted on the server is removed locally only if you never edited it.
510
574
 
@@ -512,7 +576,7 @@ It ends with a summary line: written, pending, kept, removed.
512
576
 
513
577
  ### Push
514
578
 
515
- `sb code push` builds a plan against the manifest:
579
+ `sb site code push` builds a plan against the manifest:
516
580
 
517
581
  | Plan | When | Needs |
518
582
  | --- | --- | --- |
@@ -523,7 +587,7 @@ It ends with a summary line: written, pending, kept, removed.
523
587
  Creates run first, then updates, then deletes. Each update and delete carries the
524
588
  `updatedAt` from your last pull, and **the server compares it inside the write**:
525
589
  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,
590
+ one file is refused ("changed in the Code Dock since your pull; run sb site code pull,
527
591
  or push --force"), the rest of the run continues, and the exit code is `1`.
528
592
 
529
593
  **The manifest is written after every operation**, so a run that stops halfway —
@@ -588,14 +652,14 @@ A `wbk_` key whose manifest shares **no** file with the server's list is refused
588
652
  as belonging to a different site, so a CI key cannot write site A's files onto
589
653
  site B. `--force` overrides it.
590
654
 
591
- ### CI for `sb code`
655
+ ### CI for `sb site code`
592
656
 
593
657
  Create an API key in the merchant's **Settings → API keys** with `codefiles.write`
594
658
  (add `pages.read` if CI creates files in a page folder the manifest does not
595
659
  know yet), and store it as the CI secret `SB_TOKEN`:
596
660
 
597
661
  ```bash
598
- SB_TOKEN="$SB_API_KEY" sb code push
662
+ SB_TOKEN="$SB_API_KEY" sb site code push
599
663
  ```
600
664
 
601
665
  A key without `codefiles.write` is refused by the server and nothing is written.
@@ -612,41 +676,42 @@ file missing locally without `--delete`, is printed and is **not** a failure.
612
676
 
613
677
  ---
614
678
 
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
679
  ## `sb site` — a site as a repo you build with AI, synced with GitHub
638
680
 
639
681
  ```
640
- npm create sbuilder-app # or: sb init — "a new website, built by AI" is choice 1
682
+ sb init # a menu: "a new website, built by AI" is choice 1
683
+ sb site new "a shop selling handmade candles" # the same, from the command line
641
684
  sb site init my-shop --github # a repo for one of your sites, on a private GitHub repo
642
685
  sb site pull # take what was edited in the editor
643
686
  sb site push # save edited page files as DRAFTS
644
687
  sb site publish --all # make pages live (or name files)
645
688
  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
- ```
689
+ sb site mcp # the Store Builder MCP server, with this repo's key
690
+ ```
691
+
692
+ **`sb site new "<description>"`** creates a site (named from the first words of your
693
+ description), writes the repo below into `./<name>` (`--dir` picks another folder,
694
+ `--github` also makes the private GitHub repo) and — when Claude Code is installed —
695
+ offers to start it in that folder with your description. Signed out, it runs the
696
+ `sb login` flow first. It is exactly what choice 1 of `sb init` does.
697
+
698
+ **`sb site new --editor "<description>"`** builds in the editor instead: it opens the
699
+ editor, which creates the site and starts building it. If `sb agent` is already
700
+ running it does the work; if not and Claude Code is installed, the command serves as
701
+ the agent itself and stays open until you press Ctrl-C. With neither, or with the
702
+ bridge switched off, the platform's assistant builds it on your plan's allowance.
703
+ The link opens only for the account that asked and lasts 15 minutes; opening it a
704
+ second time inside those 15 minutes makes a second site. While your `sb agent` is
705
+ running, every new site you start from here, the home page or the dashboard picks
706
+ "Claude Code (sb agent)"; that stays the site's setting: with no `sb agent` running
707
+ the assistant on that site stops and says so, rather than falling back to the
708
+ platform's key.
709
+
710
+ | Flag | Effect |
711
+ | --- | --- |
712
+ | `--editor` | Build in the editor (the assistant, or your `sb agent`) instead of in a repo |
648
713
 
649
- **Building with AI.** Choice 1 of `sb init` asks you to describe the website, creates
714
+ **Building with AI.** Choice 1 of `sb init` (and `sb site new`) takes your description, creates
650
715
  the site, writes the repo below and — when Claude Code is installed — starts it in
651
716
  that folder with your description, so building starts right there. Any agent works:
652
717
  the repo carries `.mcp.json`, `.cursor/mcp.json` and `.vscode/mcp.json`, so Claude
@@ -662,17 +727,17 @@ takes `--site <id>`), and writes:
662
727
  | Path | What it is |
663
728
  | --- | --- |
664
729
  | `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`) |
730
+ | `code/` | The site's Code Dock files (`sb site code pull --dir code`) |
666
731
  | `.sb-site.json` | What was last synced — commit it |
667
732
  | `.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` |
733
+ | `.mcp.json`, `.cursor/mcp.json`, `.vscode/mcp.json` | The MCP server, started as `sb site mcp` |
669
734
  | `AGENTS.md`, `CLAUDE.md` | How an AI agent works in this repo |
670
735
  | `.github/workflows/sbuilder.yml` | The GitHub half of the sync |
671
736
 
672
737
  The key is named `AI agent · <folder>` and carries every content permission your
673
738
  account may delegate — never members, roles, site settings or export. Revoke it in
674
739
  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
740
+ repo, `sb site`, `sb site code` and `sb site mcp` read `.env`; a variable already set in your
676
741
  shell wins. `--github` then runs `git init`, the first commit, `gh repo create
677
742
  --private --push` and `gh secret set SB_TOKEN` (the key goes in on stdin, never on a
678
743
  command line) — the workflow is live with nothing left to paste.
@@ -734,27 +799,24 @@ or deleted from files: create one in the editor (or let the agent), then pull; a
734
799
  deleted on the platform keeps its file and is named. With an API key it uses
735
800
  `/api/v1/pages/{id}/document` and needs no `--site`.
736
801
 
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
- ```
802
+ ## What changed in 0.9
742
803
 
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.
804
+ The commands moved into groups. **The old names still work in 0.9** and print one
805
+ line on stderr naming the new form (stdout is untouched — `sb mcp` speaks the MCP
806
+ protocol over it, and repos made by 0.8 still start it):
747
807
 
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.
808
+ | 0.8 | 0.9 |
809
+ | --- | --- |
810
+ | `sb dev` | `sb app dev` |
811
+ | `sb deploy` | `sb app deploy` |
812
+ | `sb code …` | `sb site code …` |
813
+ | `sb new "…"` | `sb site new --editor "…"` |
814
+ | `sb mcp` | `sb site mcp` |
815
+ | `sb init <name>` | `sb app init <name>` |
753
816
 
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.
817
+ `sb export next` was **removed**: `sb site next` makes a Next.js app rendered by the
818
+ platform's own renderer, which a snapshot of published HTML never was. `sb export …`
819
+ now exits `1` and says so.
758
820
 
759
821
  ## `sb agent` — the editor assistant on your own login
760
822
 
@@ -816,11 +878,11 @@ A user access token expires, so it is the wrong credential for a pipeline. Use a
816
878
  1. In the Developer portal, open your organization and go to **Deploy keys**
817
879
  (an owner or admin can do this), then create one. The secret starts with
818
880
  `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.)
881
+ 2. Store it as the CI secret `SB_TOKEN`. `sb app dev` and `sb app deploy` accept it
882
+ exactly like a pasted token. (`sb site code` does not: see its own CI recipe.)
821
883
 
822
884
  ```bash
823
- SB_TOKEN="$SB_DEPLOY_KEY" sb deploy
885
+ SB_TOKEN="$SB_DEPLOY_KEY" sb app deploy
824
886
  ```
825
887
 
826
888
  A deploy key does not expire and belongs to the organization, not to the person
@@ -840,27 +902,27 @@ Three are read by the CLI itself:
840
902
 
841
903
  | Variable | Required by | Default |
842
904
  | --- | --- | --- |
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 |
905
+ | `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` |
906
+ | `SB_API` | every command but `sb app init` | `https://api.sbuilder.io.vn` — set `http://localhost:8080` for a local platform |
845
907
  | `SB_NO_BROWSER` | `sb login` | unset — set it to stop `sb login` opening the `/device` page (CI and non-terminals never open it) |
846
908
  | `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
909
 
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
910
+ `SB_TOKEN` **overrides** the stored `sb login` credential when set. For `sb app dev`
911
+ and `sb app deploy` it is a token for the **organization that owns the app** — the
850
912
  same user access token you would put in an `Authorization: Bearer` header against
851
913
  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
914
+ install, and an install cannot edit the app it is an install of. For `sb site code` it
853
915
  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)).
916
+ [`sb site code`](#sb-site-code--your-code-dock-files-as-a-folder)).
855
917
 
856
918
  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
919
+ the server refuses a pasted token, `sb app dev` and `sb app deploy` say
858
920
  `SB_TOKEN was refused: it has expired or been revoked` and point you at
859
- `sb login`. `sb code` says
921
+ `sb login`. `sb site code` says
860
922
  ``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.
923
+ instead, and never suggests a deploy key, because `sb site code` refuses one.
862
924
 
863
- Three more are read by the app `sb init` writes, from its own `.env`:
925
+ Three more are read by the app `sb app init` writes, from its own `.env`:
864
926
 
865
927
  | Variable | Read by | What it is |
866
928
  | --- | --- | --- |
@@ -878,9 +940,9 @@ Every command exits `0` on success and `1` on a refusal it can explain. Anything
878
940
  else is a bug in the tool and gets a stack trace, because a scaffolder that
879
941
  swallows its own failures is one nobody can report.
880
942
 
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)
943
+ `sb app dev` and `sb app deploy` translate the server codes below rather than passing
944
+ them through verbatim. `sb site code` words its own refusals: the refused-token one
945
+ is above, and the [`sb site code`](#sb-site-code--your-code-dock-files-as-a-folder)
884
946
  section describes the command.
885
947
 
886
948
  | Server code | What `sb` says instead |
@@ -902,15 +964,16 @@ shrug.
902
964
 
903
965
  Stated so you can plan around it rather than discover it.
904
966
 
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.
967
+ - **`sb app init` makes no network calls.** Registering the app is `sb app create`,
968
+ which makes a *draft* and a *sandbox* install on your own store — nothing is
969
+ submitted for review or made public, and it never creates an organization.
970
+ - **It never prints the client secret.** It goes to `.env` (mode `0600`) and nowhere
971
+ else; lose it and rotate it in the developer portal.
909
972
  - **It never asks for a password.** `sb login` signs in through the browser,
910
973
  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
974
+ - **`sb app dev` is not hot reload**, and no future version of it can be while an
912
975
  island's code is served from the platform's object store.
913
- - **`sb deploy` is not atomic**, deliberately.
976
+ - **`sb app deploy` is not atomic**, deliberately.
914
977
 
915
978
  ---
916
979
 
@@ -918,18 +981,19 @@ Stated so you can plan around it rather than discover it.
918
981
 
919
982
  | Symptom | Cause | Fix |
920
983
  | --- | --- | --- |
921
- | `Not signed in. Run sb login …` | `dev`/`deploy` have no credential | `sb login`, or set `SB_TOKEN` |
984
+ | `Not signed in. Run sb login …` | `sb app dev` / `sb app deploy` have no credential | `sb login`, or set `SB_TOKEN` |
922
985
  | `Your sb login has expired or was revoked.` | The stored session ended (signed out everywhere, or it lapsed) | `sb login` again |
923
986
  | `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 |
987
+ | `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
988
  | `No sb.json here.` | Run from the wrong directory | `cd` to the folder holding `sb.json` |
989
+ | `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
990
  | `sb.json is missing "versionId".` | A required key is absent or empty | Add all five required keys |
927
991
  | `unknown command: …` | Typo, or a stale `dist/` | `npm run build --workspace cli` |
928
992
  | `--port must be a number` | `--port` got a non-positive or non-numeric value | Pass a positive integer |
929
993
  | 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 |
994
+ | 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 |
995
+ | `--submit` refused for loopback URLs | `version.embedUrl` / `version.redirectUri` still point at localhost | Set public `https` URLs, `sb app deploy` again, then submit |
996
+ | The island changed and the page did not | `sb app dev` is not hot reload | Refresh the page |
933
997
  | `sb` reports a flag this page does not list | You are running an older `dist/` | Rebuild |
934
998
 
935
999
  ---