@sbuilder/cli 0.12.0 → 0.14.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 +116 -13
- package/README.vi.md +115 -13
- package/dist/bin/sb.js +221 -41
- package/dist/bin/sb.js.map +1 -1
- package/dist/src/agentdocs.js +250 -8
- package/dist/src/agentdocs.js.map +1 -1
- package/dist/src/appblocks.js +5 -1
- package/dist/src/appblocks.js.map +1 -1
- package/dist/src/components.js +400 -24
- package/dist/src/components.js.map +1 -1
- package/dist/src/doctor.js +37 -3
- package/dist/src/doctor.js.map +1 -1
- package/dist/src/envtypes.gen.js +2929 -271
- package/dist/src/envtypes.gen.js.map +1 -1
- package/dist/src/host.js +31 -0
- package/dist/src/host.js.map +1 -1
- package/dist/src/login.js +1 -1
- package/dist/src/preview.js +114 -0
- package/dist/src/preview.js.map +1 -0
- package/dist/src/route.js +4 -2
- package/dist/src/route.js.map +1 -1
- package/dist/src/site.js +164 -22
- package/dist/src/site.js.map +1 -1
- package/dist/src/siteinit.js +381 -74
- package/dist/src/siteinit.js.map +1 -1
- package/dist/src/sitekinds.js +56 -13
- package/dist/src/sitekinds.js.map +1 -1
- package/dist/src/source/derived.js +96 -0
- package/dist/src/source/derived.js.map +1 -0
- package/dist/src/source/meta.js +3 -3
- package/dist/src/source/meta.js.map +1 -1
- package/dist/src/source/parse.js +6 -2
- package/dist/src/source/parse.js.map +1 -1
- package/dist/src/source/print.js +8 -1
- package/dist/src/source/print.js.map +1 -1
- package/dist/src/structure.js +114 -0
- package/dist/src/structure.js.map +1 -0
- package/dist/src/templates.js +93 -0
- package/dist/src/templates.js.map +1 -0
- package/dist/src/themediff.js +49 -0
- package/dist/src/themediff.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,9 +7,10 @@ editor's AI assistant on your own machine, and build apps for the platform.
|
|
|
7
7
|
|
|
8
8
|
```
|
|
9
9
|
Start
|
|
10
|
-
sb init ask what to start: a new website built by AI,
|
|
11
|
-
repo for one of your sites,
|
|
12
|
-
npm create
|
|
10
|
+
sb init ask what to start: a new website built by AI, one
|
|
11
|
+
from a template, a repo for one of your sites, an
|
|
12
|
+
app or a Next.js storefront (same as npm create
|
|
13
|
+
sbuilder-app)
|
|
13
14
|
|
|
14
15
|
Account
|
|
15
16
|
sb login sign in through the browser; stores a credential
|
|
@@ -24,6 +25,9 @@ Sites
|
|
|
24
25
|
sb site new "<description>" [--dir <path>] [--github] [--editor]
|
|
25
26
|
make a site from one sentence, in a repo an AI
|
|
26
27
|
agent builds in (--editor: in the editor instead)
|
|
28
|
+
sb site new --template <slug|id> ["<description>"] [--dir <path>] [--github]
|
|
29
|
+
a new site copied from a template, in the same repo
|
|
30
|
+
sb site templates [--json] the templates a new site can start from
|
|
27
31
|
sb site init [dir] [--site <id>] [--github]
|
|
28
32
|
a repo holding one site's pages, synced with
|
|
29
33
|
GitHub both ways
|
|
@@ -36,6 +40,8 @@ Sites
|
|
|
36
40
|
sb site dev [--theme] watch design/ and code/, push each save as a DRAFT
|
|
37
41
|
sb site publish <file>… | --all
|
|
38
42
|
make pages LIVE — named files, or every page
|
|
43
|
+
sb site preview <file> [--open] [--html]
|
|
44
|
+
a link to the page's DRAFT, rendered — nothing published
|
|
39
45
|
sb site blocks the blocks your installed apps offer, with the line
|
|
40
46
|
to paste into a page file
|
|
41
47
|
sb site next serve the pages from a Next.js app, rendered by the
|
|
@@ -45,10 +51,16 @@ Sites
|
|
|
45
51
|
sb site code push [--site <id>] [--dir <path>] [--force] [--dry-run] [--delete]
|
|
46
52
|
send local edits back; refuses a file changed
|
|
47
53
|
in the Code Dock since your pull unless --force
|
|
48
|
-
sb site components init | upgrade <Name> [--to <n>] [--dry-run]
|
|
54
|
+
sb site components init | list [--json] | upgrade <Name> [--to <n>] [--dry-run]
|
|
49
55
|
code components: set the repo up (components/Hero.tsx);
|
|
50
|
-
move a component's pins
|
|
51
|
-
sb site
|
|
56
|
+
list them on the platform; move a component's pins
|
|
57
|
+
sb site components preview <Name> [--props <json|@file>] [--json]
|
|
58
|
+
build one here and render it once on the platform
|
|
59
|
+
sb site components delete <Name> <version> [--yes] [--dry-run]
|
|
60
|
+
delete one version (refused while a page uses it;
|
|
61
|
+
a number is never reused)
|
|
62
|
+
sb site agents [--refresh] write the AI-agent files into this repo (never overwrites;
|
|
63
|
+
--refresh updates the ones the CLI wrote, unedited)
|
|
52
64
|
sb site types [--dir <path>] [--quiet]
|
|
53
65
|
write design/sbuilder-env.d.ts: types for the .page.tsx files
|
|
54
66
|
sb site mcp the Store Builder MCP server, with this repo's key
|
|
@@ -189,7 +201,7 @@ sb app init my-app --with-block
|
|
|
189
201
|
|
|
190
202
|
Writes a working app into `./my-app` and prints what to do next. It makes **no
|
|
191
203
|
network calls at all** — it is a scaffolder; `sb app create` (below) registers
|
|
192
|
-
it. A bare `sb init` on a terminal asks what to start instead; its choice
|
|
204
|
+
it. A bare `sb init` on a terminal asks what to start instead; its choice 4 runs
|
|
193
205
|
this flow.
|
|
194
206
|
|
|
195
207
|
### What it writes
|
|
@@ -701,6 +713,8 @@ file missing locally without `--delete`, is printed and is **not** a failure.
|
|
|
701
713
|
```
|
|
702
714
|
sb init # a menu: "a new website, built by AI" is choice 1
|
|
703
715
|
sb site new "a shop selling handmade candles" # the same, from the command line
|
|
716
|
+
sb site new --template tea-shop # a new site copied from a template, in a repo like the one below
|
|
717
|
+
sb site templates # the templates to start from (--json for the list as JSON)
|
|
704
718
|
sb site init my-shop --github # a repo for one of your sites, on a private GitHub repo
|
|
705
719
|
sb site pull # take what was edited in the editor
|
|
706
720
|
sb site push # save edited page files as DRAFTS
|
|
@@ -709,10 +723,12 @@ sb site push --theme # also send design/theme.json (a theme save is
|
|
|
709
723
|
sb site status # what differs from the last sync; stale translations
|
|
710
724
|
sb site dev # watch design/ and code/ and push each save as a DRAFT
|
|
711
725
|
sb site publish --all # make pages live (or name files)
|
|
726
|
+
sb site preview design/pages/index.page.tsx # a link to that page's DRAFT, rendered (--open opens it, --html prints it); nothing published
|
|
712
727
|
sb site next # serve the pages from a Next.js app (npm run dev)
|
|
713
728
|
sb site next --link # mint the host secret into .env: a deployed host signs its requests
|
|
714
729
|
sb site deploy --vercel # one command to production on Vercel, with your own vercel CLI (--dry-run: the plan; --rotate replaces a link made elsewhere)
|
|
715
730
|
sb site agents # the AI-agent files, for a repo made by an older CLI
|
|
731
|
+
sb site agents --refresh # bring them to this CLI's text; an edited one gets <file>.new
|
|
716
732
|
sb site types # design/sbuilder-env.d.ts: completion + checks for .page.tsx
|
|
717
733
|
sb site types --quiet # the same, silent: what a Next app's predev / prebuild run
|
|
718
734
|
sb site mcp # the Store Builder MCP server, with this repo's key
|
|
@@ -724,7 +740,18 @@ description), writes the repo below into `./<name>` (`--dir` picks another folde
|
|
|
724
740
|
offers to start it in that folder with your description. Signed out, it runs the
|
|
725
741
|
`sb login` flow first. It is exactly what choice 1 of `sb init` does.
|
|
726
742
|
|
|
727
|
-
|
|
743
|
+
**`sb site new --template <slug|id>`** starts from a design instead of a sentence. It copies
|
|
744
|
+
the template into a new site in your account through the platform's own copy (pages, theme,
|
|
745
|
+
Code Dock files and code components come along), waits for the copy to finish, then writes
|
|
746
|
+
the same repo as `sb site init` around it. A description after the flag
|
|
747
|
+
(`sb site new --template tea-shop "a tea house in Hanoi"`) names the site and becomes the brief
|
|
748
|
+
Claude Code is offered, to adapt the design; without one the site takes the template's name.
|
|
749
|
+
**`sb site templates`** lists what there is to start from — slug, name, categories, the live
|
|
750
|
+
template and its preview image — and needs no sign-in. Choice 2 of `sb init` is the same flow
|
|
751
|
+
with a numbered list. The copy is made in your account's name, so it needs `sb login`, not an
|
|
752
|
+
API key.
|
|
753
|
+
|
|
754
|
+
**The Next.js storefront starter** is choice 5 of `sb init` (the menu `npm create sbuilder-app` shows). It picks one of your sites, writes its repo like `sb site init`, runs `sb site next`, adds `@sbuilder/sdk` and one hand-written route, `app/api/featured/route.ts` (JSON), which lists the store's products through `@sbuilder/sdk/storefront` (no API key, so it also works on a deployed host). The page types (`design/sbuilder-env.d.ts`) come with the repo. Then `npm install && npm run dev`, and `sb site deploy --vercel` when you want it online.
|
|
728
755
|
|
|
729
756
|
**`sb site new --editor "<description>"`** builds in the editor instead: it opens the
|
|
730
757
|
editor, which creates the site and starts building it. If `sb agent` is already
|
|
@@ -741,6 +768,7 @@ platform's key.
|
|
|
741
768
|
| Flag | Effect |
|
|
742
769
|
| --- | --- |
|
|
743
770
|
| `--editor` | Build in the editor (the assistant, or your `sb agent`) instead of in a repo |
|
|
771
|
+
| `--template <slug\|id>` | Copy that template into the new site instead of starting empty (`sb site templates` lists them) |
|
|
744
772
|
|
|
745
773
|
**Building with AI.** Choice 1 of `sb init` (and `sb site new`) takes your description, creates
|
|
746
774
|
the site, writes the repo below and — when Claude Code is installed — starts it in
|
|
@@ -754,6 +782,28 @@ the agent how to work: native elements first, look at every section on desktop a
|
|
|
754
782
|
mobile, ask for real facts, pull the result into the repo, **never publish unasked**.
|
|
755
783
|
The agent edits the site's drafts; you review what it did as a git diff.
|
|
756
784
|
|
|
785
|
+
**`sb site preview <file>`** prints a link to that page's current DRAFT on the storefront,
|
|
786
|
+
rendered exactly as a visitor would see it once published — the editor's own Preview, from the
|
|
787
|
+
terminal. Nothing is published. The link works for an hour; `--open` opens it in the browser,
|
|
788
|
+
`--html` prints the rendered HTML instead. It shows what was last PUSHED (a file with edits not
|
|
789
|
+
pushed yet says so). It is minted with your `sb login` (or `SB_TOKEN`) when there is one, sent
|
|
790
|
+
only to that platform; otherwise with the repo's API key in `.env` (it needs `pages.read`), sent to
|
|
791
|
+
the `.env`'s own `SB_API` — the pair every site command uses.
|
|
792
|
+
|
|
793
|
+
**Structure is checked before anything is sent.** Every element must sit where the schema allows
|
|
794
|
+
it — a parent's allowed children (an `<Accordion>` holds only `<AccordionContent>`) and the
|
|
795
|
+
section types that live only directly in `<Page>`. `sb site push` and `sb site dev` check each
|
|
796
|
+
file they are about to send: one that breaks this is not sent, with `file:line:col` and what to
|
|
797
|
+
write instead (a removed element type: delete it), while the other files go; push then exits 1.
|
|
798
|
+
The rules are this CLI's copy of the schema — the message says which version, and if the editor
|
|
799
|
+
allows what it refuses, upgrade sb. `sb doctor` reports it for every file. `design/sbuilder-env.d.ts`
|
|
800
|
+
carries each element's purpose, its allowed children and an example, from the schema.
|
|
801
|
+
|
|
802
|
+
**The theme.** `sb site pull` writes `design/theme.json` — the site's saved theme, or the
|
|
803
|
+
default it renders with while it has none. A theme save is live at once, so `sb site push`
|
|
804
|
+
sends it only with `--theme`, and `sb site push --theme --dry-run` prints each token that would
|
|
805
|
+
change (`colors.primary: value #171717 → #e11d48`) and sends nothing.
|
|
806
|
+
|
|
757
807
|
**What `sb site init` writes.** It signs you in if needed, lets you pick a site (or
|
|
758
808
|
takes `--site <id>`), and writes:
|
|
759
809
|
|
|
@@ -766,12 +816,22 @@ takes `--site <id>`), and writes:
|
|
|
766
816
|
| `.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 |
|
|
767
817
|
| `AGENTS.md`, `CLAUDE.md`, `GEMINI.md` | How an AI agent works in this repo; the other two import `AGENTS.md` |
|
|
768
818
|
| `.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 |
|
|
819
|
+
| `.claude/skills/sbuilder-components/SKILL.md` | Code components for an agent: when one is right (native elements first), the file and props rules, the sandbox it renders in, the `<CodeComponent …/>` line and the push / pin / upgrade / delete loop. `sb site components init` writes it too |
|
|
769
820
|
| `.github/workflows/sbuilder.yml` | The GitHub half of the sync |
|
|
770
821
|
| `design/sbuilder-env.d.ts`, `design/tsconfig.json` | Types for the page files (see *Page types* below) — commit them; `sb site types` regenerates the first |
|
|
771
822
|
|
|
772
823
|
None of the agent files above is overwritten. One that is already there is kept — silently when it
|
|
773
824
|
is what init would write, otherwise with a note saying what it lacks and the exact text to add.
|
|
774
825
|
`sb site agents` writes just these files into a repo made by an older version of the CLI, with the same rule.
|
|
826
|
+
`sb site agents --refresh` brings them — and `.github/workflows/sbuilder.yml`, which pins the CLI too —
|
|
827
|
+
to this CLI's text without clobbering an edit: `.sb-site.json` records the sha of each file as the CLI
|
|
828
|
+
wrote it, and a file still holding that sha is rewritten (re-checked at the moment of the write). One
|
|
829
|
+
edited since, or one the CLI never recorded (a repo made before 0.13, your own `AGENTS.md`), is kept and
|
|
830
|
+
today's text is written beside it as `<file>.new` (or `<file>.new.2`, … when a `.new` of your own is
|
|
831
|
+
there), named, for you to merge; the exit is then 1. **To keep your version as it is, delete the
|
|
832
|
+
`.new`**: the next refresh records your file as kept, says so, and stops asking — `sb doctor` too —
|
|
833
|
+
until the CLI's own text for that file changes. A deleted agent file is re-created; a deleted workflow
|
|
834
|
+
is not (CI may be off on purpose). `sb doctor` warns when an agent file is not this sb's.
|
|
775
835
|
A symbolic link in the way of any file init writes (`.env`, `.github`, …) is refused before the
|
|
776
836
|
key is minted (an agent file behind a link is skipped with a note instead), and an existing
|
|
777
837
|
`.env` is never replaced. A folder's own `.gitignore` is kept — init only adds `node_modules` and
|
|
@@ -784,6 +844,9 @@ repo, `sb site`, `sb site code` and `sb site mcp` read `.env`; a variable alread
|
|
|
784
844
|
shell wins. `--github` then runs `git init`, the first commit, `gh repo create
|
|
785
845
|
--private --push` and `gh secret set SB_TOKEN` (the key goes in on stdin, never on a
|
|
786
846
|
command line) — the workflow is live with nothing left to paste.
|
|
847
|
+
Without `--github`, init still runs `git init` and makes the first commit when the folder is not
|
|
848
|
+
inside a git repo already and git is installed (it says which), so every later pull or agent
|
|
849
|
+
edit shows as a git diff.
|
|
787
850
|
|
|
788
851
|
**Page files.** Each page is a `.page.tsx` file that reads like React — one tag per element,
|
|
789
852
|
its settings as props:
|
|
@@ -953,7 +1016,8 @@ changing `name`, `slug`, `type`, `isHomepage`, `settings` or `defaultTemplate` i
|
|
|
953
1016
|
file renames or re-types it. `path` is derived and only informational. When the platform
|
|
954
1017
|
settles on something other than what you asked (a slug is made unique) push says so, and
|
|
955
1018
|
after every save the file is rewritten to what the platform stored — minted ids and the
|
|
956
|
-
facts it settled on
|
|
1019
|
+
facts it settled on, with shared sections and overlays in place as a pull writes them — so
|
|
1020
|
+
the next `sb site pull` changes nothing. A file with no
|
|
957
1021
|
`export const page` and no manifest entry is still only reported.
|
|
958
1022
|
|
|
959
1023
|
Facts are merged three ways like the document: what was last synced is the base. A fact only
|
|
@@ -970,7 +1034,8 @@ With an API key (`/api/v1`) the platform also fences the write itself: each fact
|
|
|
970
1034
|
pages: it lists them first, asks on a terminal, and off a terminal also needs `--yes`
|
|
971
1035
|
(nothing is deleted otherwise). `--prune` refuses when `design/pages/` is absent, since
|
|
972
1036
|
every page would then look deleted. A page deleted on the platform keeps its file, named
|
|
973
|
-
by pull.
|
|
1037
|
+
by pull. A tracked file you deleted stays deleted on `sb site pull` (named, exit 0) until you
|
|
1038
|
+
prune the page; `sb site pull --force` writes it back.
|
|
974
1039
|
|
|
975
1040
|
### The rest of the site as files
|
|
976
1041
|
|
|
@@ -1014,6 +1079,11 @@ sb site components init # esbuild + preact into devDepende
|
|
|
1014
1079
|
sb site push # bundles each components/<Name>.tsx and uploads it, then the pages
|
|
1015
1080
|
sb site components upgrade Hero # move every page's pin of Hero to its latest version
|
|
1016
1081
|
sb site components upgrade Hero --to 3 --dry-run
|
|
1082
|
+
sb site components preview Hero --props '{"title":"Hi"}' # build it here, render it once on the platform
|
|
1083
|
+
sb site components list # each component: latest version, how many, sizes, created
|
|
1084
|
+
sb site components list --json # the same, as JSON
|
|
1085
|
+
sb site components delete Hero 2 # delete one version (asks first; --yes off a terminal)
|
|
1086
|
+
sb site components delete Hero 2 --dry-run # say what would be deleted, delete nothing
|
|
1017
1087
|
```
|
|
1018
1088
|
|
|
1019
1089
|
A code component is a React (Preact) component in `components/<Name>.tsx` that exports its props
|
|
@@ -1035,8 +1105,40 @@ component, so the published page hydrates it in the browser — every code compo
|
|
|
1035
1105
|
`<CodeComponent …/>`) always names a version that exists. Nothing on any page moves by itself.
|
|
1036
1106
|
- **Upgrading is a local edit.** `sb site components upgrade <Name> [--to <n>]` rewrites the pins
|
|
1037
1107
|
in `design/` (pages, shared sections, overlays), names a prop the new version no longer takes,
|
|
1038
|
-
and sends nothing. Review the diff, then `sb site push` saves a draft.
|
|
1039
|
-
|
|
1108
|
+
and sends nothing. Review the diff, then `sb site push` saves a draft.
|
|
1109
|
+
- **`html`, `clientUrl` and `hydrateProps` are the platform's.** The component's rendered markup, its
|
|
1110
|
+
browser bundle's address and the sanitised props it hydrates with are derived: on every save the platform keeps them while the pin and props are
|
|
1111
|
+
unchanged and re-renders otherwise, whatever a file says. So a page file never holds them — `sb
|
|
1112
|
+
site pull` does not write them, and a file that still has one (pulled by an older `sb`, or typed
|
|
1113
|
+
by hand) is read without it: `sb site push` and `sb doctor` name the file, the node and the key
|
|
1114
|
+
(`` `html` on code-component cc_1 is rendered by the platform; your edit is ignored. ``). A file
|
|
1115
|
+
you have not edited since an older `sb` pulled it is rewritten without them on the next `sb site
|
|
1116
|
+
pull`. The Next host (`sb site next`) previews each component with the markup the platform
|
|
1117
|
+
stored for it. One whose pin or props you changed locally, whose last render on the platform
|
|
1118
|
+
failed, or whose stored draft could not be read shows without it — said once on the console and
|
|
1119
|
+
named on every response in `x-sbuilder-unrendered` — until `sb site push` renders it.
|
|
1120
|
+
- **Previewing.** `sb site components preview <Name> [--props <json|@file>] [--json]` builds
|
|
1121
|
+
`components/<Name>.tsx` here, exactly as push does, and has the platform render it once in the same
|
|
1122
|
+
sandbox (`POST /api/v1/code-components/preview`): it prints the HTML a page save would store
|
|
1123
|
+
(`--json`: `{"html": …}`). Props the schema names but `--props` omits take their default; unknown
|
|
1124
|
+
and `css` props are dropped, as on a page save. Nothing is uploaded and no page changes. A refusal
|
|
1125
|
+
— `bundle_rejected` with the sandbox's own error, `invalid_props` naming the prop, `css_prop_name`,
|
|
1126
|
+
a size cap — prints its code and message and exits 1, which is what an agent reads to fix the
|
|
1127
|
+
component. A busy platform (429 / 503) prints its `Retry-After` and exits 1; nothing retries.
|
|
1128
|
+
`--dry-run` only builds. It needs an API key (`wbk_…`, `pages.write`).
|
|
1129
|
+
- **For an AI agent.** `sb site init` and `sb site components init` write
|
|
1130
|
+
`.claude/skills/sbuilder-components/SKILL.md` and `AGENTS.md` points at it: when a code component
|
|
1131
|
+
is right (native elements first), the props and sandbox rules above, the `<CodeComponent …/>` line
|
|
1132
|
+
and this loop. Its example component is built and its page snippet parsed by the CLI's own tests.
|
|
1133
|
+
- **Listing and deleting.** `sb site components list [--json]` shows every component on the
|
|
1134
|
+
platform with its latest version, how many versions it has, each version's SSR and client size
|
|
1135
|
+
and when it was made, and which versions the files in this repo pin (the platform's own drafts
|
|
1136
|
+
and live pages are not listed). `sb site components delete <Name> <version> [--yes]` deletes one
|
|
1137
|
+
version: it asks first, and off a terminal it needs `--yes`; `--dry-run` deletes nothing: it reads
|
|
1138
|
+
the version, so a missing one is named, and only the real delete can tell whether a page pins it. While any draft or live page, shared
|
|
1139
|
+
section or overlay still uses that version the platform refuses: the pages it names are printed
|
|
1140
|
+
and the exit is 1. **A deleted number is never reused** — the next upload gets a new one, so a
|
|
1141
|
+
pin can never come to mean different code. Deleting needs an API key (`wbk_…`, `pages.write`).
|
|
1040
1142
|
- **Limits.** SSR bundle 512 KiB, client bundle 256 KiB (named locally before any upload), one
|
|
1041
1143
|
second to render, a clock frozen at 2000-01-01 and a seeded `Math.random` (`fetch`, timers and
|
|
1042
1144
|
`crypto` throw), no
|
|
@@ -1075,7 +1177,8 @@ so: it also bundles `components/`, which loads and **runs the repo's own esbuild
|
|
|
1075
1177
|
| `scope:write` | the write scopes — **not probed** (a GET cannot test a write); it says what each one gates | never |
|
|
1076
1178
|
| `site` | `sb.json` names a site this key or login reaches, and `.sb-site.json` is from the same one | no `siteId`, bad JSON, another site's manifest, a site you cannot read |
|
|
1077
1179
|
| `manifest` | `.sb-site.json`: every path inside its kind's folder under `design/`, no symbolic links | a path outside `design/`, a symbolic link (a missing file is a `warn`) |
|
|
1078
|
-
| `files` | every file under `design/` parses | any does not: it prints `file:line:col` |
|
|
1180
|
+
| `files` | every file under `design/` parses | any does not: it prints `file:line:col`. A warning names a file that still holds a code component's `html` or `clientUrl` (the platform's; ignored) |
|
|
1181
|
+
| `agents` | in a site repo, every agent file (`AGENTS.md`, the skills, the MCP configs, the CI workflow) is the text this CLI writes, or one you kept | one differs or is missing (warning): `sb site agents --refresh` |
|
|
1079
1182
|
| `components:build` | `components/<Name>.tsx` files with a literal `schema`, and `esbuild` installed in the repo (its `package.json` is looked for — never loaded). Static: **no repo code runs** | a file's `schema` is not a literal, a symbolic link, esbuild missing. With `--build` also: a component that does not build or is over a size cap |
|
|
1080
1183
|
| `components:pins` | every `<CodeComponent version={n}>` in `design/` names a version the platform has (GET) | one does not (`sb site components upgrade`, or `sb site push` to upload it) |
|
|
1081
1184
|
| `domain` | the store's primary domain against `SB_PUBLIC_URL`, and the built-in address's redirect | they differ; the built-in address redirects to your deployment (the loop — fix: Manage → Domains → Default address → *Serve this site directly*) |
|
package/README.vi.md
CHANGED
|
@@ -8,8 +8,8 @@ trợ lý AI của editor trên máy bạn, và xây app cho nền tảng.
|
|
|
8
8
|
```
|
|
9
9
|
Bắt đầu
|
|
10
10
|
sb init hỏi bạn muốn bắt đầu gì: website mới do AI dựng,
|
|
11
|
-
repo cho một site của bạn,
|
|
12
|
-
create sbuilder-app)
|
|
11
|
+
website từ một mẫu, repo cho một site của bạn, app
|
|
12
|
+
hay Next.js storefront (giống npm create sbuilder-app)
|
|
13
13
|
|
|
14
14
|
Tài khoản
|
|
15
15
|
sb login đăng nhập qua trình duyệt; lưu một credential tự
|
|
@@ -24,6 +24,9 @@ Site
|
|
|
24
24
|
sb site new "<mô tả>" [--dir <path>] [--github] [--editor]
|
|
25
25
|
tạo site từ một câu, trong một repo để AI agent dựng
|
|
26
26
|
(--editor: dựng ngay trong editor)
|
|
27
|
+
sb site new --template <slug|id> ["<mô tả>"] [--dir <path>] [--github]
|
|
28
|
+
site mới chép từ một mẫu, trong cùng kiểu repo đó
|
|
29
|
+
sb site templates [--json] các mẫu mà một site mới có thể bắt đầu từ đó
|
|
27
30
|
sb site init [dir] [--site <id>] [--github]
|
|
28
31
|
repo chứa các trang của một site, đồng bộ hai
|
|
29
32
|
chiều với GitHub
|
|
@@ -37,6 +40,8 @@ Site
|
|
|
37
40
|
sb site dev [--theme] theo dõi design/ và code/, mỗi lần lưu là một BẢN NHÁP
|
|
38
41
|
sb site publish <file>… | --all
|
|
39
42
|
đưa trang lên LIVE — file chỉ định, hoặc mọi trang
|
|
43
|
+
sb site preview <file> [--open] [--html]
|
|
44
|
+
liên kết tới BẢN NHÁP của trang, đã render — không xuất bản
|
|
40
45
|
sb site blocks các block app đã cài cho phép đặt, kèm dòng để dán
|
|
41
46
|
vào file trang
|
|
42
47
|
sb site next phục vụ các trang từ một app Next.js, render bằng
|
|
@@ -46,10 +51,16 @@ Site
|
|
|
46
51
|
sb site code push [--site <id>] [--dir <path>] [--force] [--dry-run] [--delete]
|
|
47
52
|
gửi các chỗ sửa ở máy ngược lại; từ chối file đã
|
|
48
53
|
đổi trong Code Dock kể từ lần pull, trừ khi --force
|
|
49
|
-
sb site components init | upgrade <Name> [--to <n>] [--dry-run]
|
|
54
|
+
sb site components init | list [--json] | upgrade <Name> [--to <n>] [--dry-run]
|
|
50
55
|
code component: chuẩn bị repo (components/Hero.tsx);
|
|
51
|
-
|
|
52
|
-
sb site
|
|
56
|
+
liệt kê trên nền tảng; chuyển pin sang phiên bản khác
|
|
57
|
+
sb site components preview <Name> [--props <json|@file>] [--json]
|
|
58
|
+
build ở máy và render thử một lần trên nền tảng
|
|
59
|
+
sb site components delete <Name> <version> [--yes] [--dry-run]
|
|
60
|
+
xoá một phiên bản (bị từ chối khi còn trang dùng;
|
|
61
|
+
số phiên bản không bao giờ dùng lại)
|
|
62
|
+
sb site agents [--refresh] ghi các file cho AI agent vào repo này (không bao giờ ghi đè;
|
|
63
|
+
--refresh cập nhật các file sb đã ghi mà chưa ai sửa)
|
|
53
64
|
sb site types [--dir <path>] [--quiet]
|
|
54
65
|
ghi design/sbuilder-env.d.ts: kiểu cho các file .page.tsx
|
|
55
66
|
sb site mcp MCP server của Store Builder, với key của repo này
|
|
@@ -189,7 +200,7 @@ sb app init my-app --with-block
|
|
|
189
200
|
|
|
190
201
|
Ghi một app chạy được vào `./my-app` và in ra việc cần làm tiếp theo. Nó **không
|
|
191
202
|
gọi mạng một lần nào** — đây là công cụ tạo khung; `sb app create` (bên dưới) mới là
|
|
192
|
-
bước đăng ký. Gõ `sb init` trần trong terminal sẽ hỏi bạn muốn bắt đầu gì; lựa chọn
|
|
203
|
+
bước đăng ký. Gõ `sb init` trần trong terminal sẽ hỏi bạn muốn bắt đầu gì; lựa chọn 4
|
|
193
204
|
chạy đúng luồng này.
|
|
194
205
|
|
|
195
206
|
### Nó ghi ra những gì
|
|
@@ -703,6 +714,8 @@ theo dõi bị mất ở máy khi không có `--delete`, được in ra và **kh
|
|
|
703
714
|
```
|
|
704
715
|
sb init # một menu: lựa chọn 1 là "website mới do AI dựng"
|
|
705
716
|
sb site new "cửa hàng nến thơm thủ công" # y hệt, từ dòng lệnh
|
|
717
|
+
sb site new --template tea-shop # site mới chép từ một mẫu, trong một repo như bên dưới
|
|
718
|
+
sb site templates # các mẫu có thể bắt đầu từ đó (--json: danh sách dạng JSON)
|
|
706
719
|
sb site init my-shop --github # repo cho một site của bạn, trên repo GitHub riêng tư
|
|
707
720
|
sb site pull # lấy những gì đã sửa trong editor
|
|
708
721
|
sb site push # lưu file trang đã sửa thành BẢN NHÁP
|
|
@@ -711,10 +724,12 @@ sb site push --theme # gửi cả design/theme.json (lưu theme có
|
|
|
711
724
|
sb site status # điều khác với lần đồng bộ gần nhất; bản dịch lỗi thời
|
|
712
725
|
sb site dev # theo dõi design/ và code/, mỗi lần lưu là một BẢN NHÁP
|
|
713
726
|
sb site publish --all # xuất bản trang (hoặc chỉ định file)
|
|
727
|
+
sb site preview design/pages/index.page.tsx # liên kết tới BẢN NHÁP của trang, đã render (--open mở nó, --html in HTML); không xuất bản gì
|
|
714
728
|
sb site next # phục vụ các trang từ một app Next.js (npm run dev)
|
|
715
729
|
sb site next --link # tạo host secret vào .env: host đã deploy ký các request của nó
|
|
716
730
|
sb site deploy --vercel # một lệnh lên production trên Vercel, bằng vercel CLI của bạn (--dry-run: chỉ in kế hoạch; --rotate thay link do nơi khác tạo)
|
|
717
731
|
sb site agents # các file cho AI agent, cho repo tạo bởi bản CLI cũ
|
|
732
|
+
sb site agents --refresh # đưa chúng về văn bản của bản CLI này; file đã sửa nhận <file>.new
|
|
718
733
|
sb site types # design/sbuilder-env.d.ts: gợi ý + kiểm tra cho .page.tsx
|
|
719
734
|
sb site types --quiet # như trên, im lặng: thứ predev / prebuild của app Next chạy
|
|
720
735
|
sb site mcp # MCP server của Store Builder, với key của repo này
|
|
@@ -725,7 +740,17 @@ sb site mcp # MCP server của Store Builder, với k
|
|
|
725
740
|
— nếu máy có Claude Code — đề nghị mở nó trong thư mục đó với mô tả của bạn. Nếu chưa đăng
|
|
726
741
|
nhập, nó chạy luồng `sb login` trước. Đây đúng là việc lựa chọn 1 của `sb init` làm.
|
|
727
742
|
|
|
728
|
-
|
|
743
|
+
**`sb site new --template <slug|id>`** bắt đầu từ một thiết kế thay vì một câu mô tả. Lệnh chép
|
|
744
|
+
mẫu vào một site mới trong tài khoản của bạn bằng chính tính năng sao chép của nền tảng (trang,
|
|
745
|
+
theme, file Code Dock và code component đều đi kèm), chờ việc sao chép xong, rồi viết đúng repo
|
|
746
|
+
như `sb site init` quanh site đó. Một mô tả sau flag
|
|
747
|
+
(`sb site new --template tea-shop "quán trà ở Hà Nội"`) đặt tên site và trở thành yêu cầu đưa cho
|
|
748
|
+
Claude Code để chỉnh lại thiết kế; không có mô tả thì site lấy tên của mẫu.
|
|
749
|
+
**`sb site templates`** liệt kê các mẫu — slug, tên, danh mục, site thật của mẫu và ảnh xem trước —
|
|
750
|
+
và không cần đăng nhập. Lựa chọn 2 của `sb init` là cùng luồng này với một danh sách đánh số.
|
|
751
|
+
Bản sao được tạo dưới tên tài khoản của bạn, nên cần `sb login`, không dùng được API key.
|
|
752
|
+
|
|
753
|
+
**Starter Next.js storefront** là lựa chọn 5 của `sb init` (menu mà `npm create sbuilder-app` hiện ra). Nó chọn một site của bạn, tạo repo như `sb site init`, chạy `sb site next`, thêm `@sbuilder/sdk` và một route viết tay, `app/api/featured/route.ts` (JSON), liệt kê sản phẩm của cửa hàng qua `@sbuilder/sdk/storefront` (không cần API key, nên chạy được cả trên host đã deploy). Kiểu cho trang (`design/sbuilder-env.d.ts`) đi kèm repo. Sau đó `npm install && npm run dev`, và `sb site deploy --vercel` khi muốn đưa lên mạng.
|
|
729
754
|
|
|
730
755
|
**`sb site new --editor "<mô tả>"`** dựng trong editor: lệnh mở editor, editor tạo site và
|
|
731
756
|
bắt đầu dựng. Nếu `sb agent` đang chạy thì `sb agent` làm việc này; nếu chưa chạy mà máy có
|
|
@@ -740,6 +765,7 @@ của nền tảng.
|
|
|
740
765
|
| Flag | Tác dụng |
|
|
741
766
|
| --- | --- |
|
|
742
767
|
| `--editor` | Dựng trong editor (trợ lý, hoặc `sb agent` của bạn) thay vì trong một repo |
|
|
768
|
+
| `--template <slug\|id>` | Chép mẫu đó vào site mới thay vì bắt đầu trống (`sb site templates` liệt kê các mẫu) |
|
|
743
769
|
|
|
744
770
|
**Dựng bằng AI.** Lựa chọn 1 của `sb init` (và `sb site new`) lấy mô tả của bạn, tạo site, viết repo
|
|
745
771
|
dưới đây và — nếu máy có Claude Code — mở nó ngay trong thư mục đó với mô tả của bạn,
|
|
@@ -751,6 +777,27 @@ không đọc `.codex/config.toml`), còn `AGENTS.md` (được `CLAUDE.md` và
|
|
|
751
777
|
từng section trên desktop và mobile, hỏi dữ liệu thật, kéo kết quả về repo, **không
|
|
752
778
|
bao giờ tự xuất bản**. Agent sửa bản nháp của site; bạn duyệt lại bằng git diff.
|
|
753
779
|
|
|
780
|
+
**`sb site preview <file>`** in ra liên kết tới BẢN NHÁP hiện tại của trang trên storefront,
|
|
781
|
+
render đúng như khách sẽ thấy khi xuất bản — chính nút Preview của editor, từ terminal. Không có
|
|
782
|
+
gì được xuất bản. Liên kết dùng được một giờ; `--open` mở nó trong trình duyệt, `--html` in ra HTML
|
|
783
|
+
đã render. Nó hiển thị bản đã PUSH gần nhất (file có chỉnh sửa chưa push sẽ được báo). Liên kết
|
|
784
|
+
được tạo bằng `sb login` (hoặc `SB_TOKEN`) nếu có, chỉ gửi tới nền tảng đó; không thì bằng
|
|
785
|
+
API key của repo trong `.env` (cần quyền `pages.read`), gửi tới `SB_API` của chính `.env` đó — cặp mà mọi lệnh
|
|
786
|
+
site đều dùng.
|
|
787
|
+
|
|
788
|
+
**Cấu trúc được kiểm tra trước khi gửi.** Mỗi phần tử phải nằm ở chỗ schema cho phép — các con
|
|
789
|
+
được phép của phần tử cha (`<Accordion>` chỉ chứa `<AccordionContent>`) và các loại section chỉ
|
|
790
|
+
nằm trực tiếp trong `<Page>`. `sb site push` và `sb site dev` kiểm tra từng file sắp gửi: file vi phạm
|
|
791
|
+
không được gửi, kèm `file:line:col` và cách viết đúng (loại phần tử đã bị gỡ: xoá nó), các file khác vẫn
|
|
792
|
+
đi; push sau đó thoát với mã 1. Luật là bản schema của chính CLI này — thông báo ghi phiên bản, và nếu
|
|
793
|
+
editor cho phép điều nó từ chối thì hãy nâng cấp sb. `sb doctor` báo cho mọi file.
|
|
794
|
+
`design/sbuilder-env.d.ts` ghi công dụng, các con được phép và ví dụ của từng phần tử, lấy từ schema.
|
|
795
|
+
|
|
796
|
+
**Theme.** `sb site pull` ghi `design/theme.json` — theme site đã lưu, hoặc theme mặc định site đang
|
|
797
|
+
dùng khi chưa lưu. Lưu theme có hiệu lực ngay, nên `sb site push` chỉ gửi nó khi có `--theme`, và
|
|
798
|
+
`sb site push --theme --dry-run` in từng token sẽ đổi (`colors.primary: value #171717 → #e11d48`) mà
|
|
799
|
+
không gửi gì.
|
|
800
|
+
|
|
754
801
|
**`sb site init` viết ra những gì.** Nó đăng nhập nếu cần, cho bạn chọn site (hoặc nhận
|
|
755
802
|
`--site <id>`), rồi viết:
|
|
756
803
|
|
|
@@ -763,12 +810,23 @@ bao giờ tự xuất bản**. Agent sửa bản nháp của site; bạn duyệt
|
|
|
763
810
|
| `.mcp.json`, `.cursor/mcp.json`, `.vscode/mcp.json`, `.gemini/settings.json`, `.codex/config.toml` | MCP server, chạy qua `sb site mcp`, cho Claude Code, Cursor, VS Code, Gemini CLI và Codex |
|
|
764
811
|
| `AGENTS.md`, `CLAUDE.md`, `GEMINI.md` | Cách một AI agent làm việc trong repo; hai file kia nạp `AGENTS.md` |
|
|
765
812
|
| `.claude/skills/sbuilder-page/SKILL.md` | Cú pháp file trang, vòng dựng từng section bằng công cụ, luật app block và pull / push / publish làm gì — `AGENTS.md` chỉ tới nó nên agent nào cũng đọc cùng một văn bản |
|
|
813
|
+
| `.claude/skills/sbuilder-components/SKILL.md` | Code component cho agent: khi nào nên dùng (ưu tiên element có sẵn), luật về file và props, sandbox nơi nó được render, dòng `<CodeComponent …/>` và vòng push / pin / upgrade / delete. `sb site components init` cũng ghi file này |
|
|
766
814
|
| `.github/workflows/sbuilder.yml` | Nửa GitHub của việc đồng bộ |
|
|
767
815
|
| `design/sbuilder-env.d.ts`, `design/tsconfig.json` | Kiểu cho các file trang (xem *Kiểu cho file trang* bên dưới) — hãy commit; `sb site types` tạo lại file đầu |
|
|
768
816
|
|
|
769
817
|
Không file agent nào ở trên bị ghi đè. File đã có sẵn được giữ nguyên — im lặng nếu nó đúng là
|
|
770
818
|
thứ init sẽ ghi, còn không thì kèm ghi chú nó thiếu gì và đoạn chữ chính xác cần thêm.
|
|
771
|
-
`sb site agents` chỉ ghi các file này vào repo tạo bởi một bản CLI cũ, cùng quy tắc đó.
|
|
819
|
+
`sb site agents` chỉ ghi các file này vào repo tạo bởi một bản CLI cũ, cùng quy tắc đó.
|
|
820
|
+
`sb site agents --refresh` đưa chúng — và `.github/workflows/sbuilder.yml`, file cũng pin bản CLI —
|
|
821
|
+
về đúng văn bản của bản CLI này mà không đè lên chỗ bạn đã sửa: `.sb-site.json` ghi sha của từng file
|
|
822
|
+
lúc sb ghi nó, và file nào vẫn giữ đúng sha đó thì được ghi lại (kiểm tra lại ngay lúc ghi). File đã bị
|
|
823
|
+
sửa từ đó, hoặc file sb chưa từng ghi nhận (repo tạo trước 0.13, `AGENTS.md` của riêng bạn), được giữ
|
|
824
|
+
nguyên và văn bản hôm nay được ghi bên cạnh thành `<file>.new` (hoặc `<file>.new.2`, … khi đã có một
|
|
825
|
+
`.new` của riêng bạn), có nêu tên, để bạn tự gộp; khi đó mã thoát là 1. **Muốn giữ nguyên bản của bạn
|
|
826
|
+
thì xoá file `.new`**: lần refresh sau ghi nhận file của bạn là được giữ, báo ra, và thôi hỏi — cả
|
|
827
|
+
`sb doctor` cũng vậy — cho tới khi văn bản của CLI cho file đó đổi. File agent bị xoá sẽ được tạo lại;
|
|
828
|
+
workflow bị xoá thì không (có thể bạn cố ý tắt CI). `sb doctor` cảnh báo khi một file agent không phải
|
|
829
|
+
của bản sb này. Một liên kết
|
|
772
830
|
mềm chặn đường của bất kỳ file nào init ghi (`.env`, `.github`, …) bị từ chối trước khi key được
|
|
773
831
|
tạo (file agent nằm sau một liên kết thì được bỏ qua kèm ghi chú), và `.env` đã có không bao giờ
|
|
774
832
|
bị thay. `.gitignore` sẵn có của thư mục được giữ — init chỉ thêm `node_modules` và `.env` vào —
|
|
@@ -781,6 +839,9 @@ Settings -> API keys. Nếu không tạo được key, init nói rõ rồi làm
|
|
|
781
839
|
`--github` chạy tiếp `git init`, commit đầu tiên, `gh repo create --private --push` và
|
|
782
840
|
`gh secret set SB_TOKEN` (key đi qua stdin, không bao giờ nằm trên dòng lệnh) — workflow
|
|
783
841
|
chạy được ngay, không phải dán gì.
|
|
842
|
+
Không có `--github`, init vẫn chạy `git init` và tạo commit đầu tiên khi thư mục chưa nằm trong
|
|
843
|
+
một repo git và máy có git (nó báo trường hợp nào), để mọi lần pull hay chỉnh sửa của agent về sau
|
|
844
|
+
đều hiện thành git diff.
|
|
784
845
|
|
|
785
846
|
**File trang.** Mỗi trang là một file `.page.tsx` đọc như React — mỗi phần tử một thẻ, cài
|
|
786
847
|
đặt của nó là prop:
|
|
@@ -942,7 +1003,8 @@ khi push; đổi `name`, `slug`, `type`, `isHomepage`, `settings` hay `defaultTe
|
|
|
942
1003
|
file đã theo dõi là đổi tên hoặc đổi loại trang. `path` được suy ra, chỉ để tham khảo. Khi
|
|
943
1004
|
nền tảng chốt khác điều bạn xin (slug bị làm cho không trùng) push sẽ nói ra, và sau mỗi
|
|
944
1005
|
lần lưu file được ghi lại đúng như nền tảng đã lưu — id mới được cấp và các thông tin nó
|
|
945
|
-
đã chốt
|
|
1006
|
+
đã chốt, cùng các phần dùng chung và overlay nằm đúng chỗ như khi pull ghi — nên `sb site
|
|
1007
|
+
pull` kế tiếp không đổi gì. File không có `export const page` và
|
|
946
1008
|
chưa có trong manifest vẫn chỉ được nêu tên.
|
|
947
1009
|
|
|
948
1010
|
Các thông tin này được trộn ba chiều như tài liệu: lần đồng bộ gần nhất là gốc. Thông tin chỉ
|
|
@@ -958,7 +1020,9 @@ Với API key (`/api/v1`) nền tảng còn rào chính lần ghi: mỗi thông
|
|
|
958
1020
|
`missing` và trang vẫn ở lại nền tảng (exit 1). `sb site push --prune` xoá các trang đó:
|
|
959
1021
|
nó liệt kê trước, hỏi lại khi chạy trên terminal, và ngoài terminal còn cần `--yes` (không
|
|
960
1022
|
thì không xoá gì). `--prune` từ chối khi không có `design/pages/`, vì khi đó mọi trang đều
|
|
961
|
-
trông như đã bị xoá. Trang bị xoá trên nền tảng vẫn giữ file, pull sẽ nêu tên.
|
|
1023
|
+
trông như đã bị xoá. Trang bị xoá trên nền tảng vẫn giữ file, pull sẽ nêu tên. File đã
|
|
1024
|
+
theo dõi mà bạn xoá thì `sb site pull` vẫn để nguyên là đã xoá (nêu tên, exit 0) cho tới khi
|
|
1025
|
+
bạn prune trang; `sb site pull --force` ghi nó lại.
|
|
962
1026
|
|
|
963
1027
|
### Phần còn lại của site thành file
|
|
964
1028
|
|
|
@@ -1002,6 +1066,11 @@ sb site components init # esbuild + preact vào devDepende
|
|
|
1002
1066
|
sb site push # đóng gói và tải lên từng components/<Name>.tsx, rồi mới đến các trang
|
|
1003
1067
|
sb site components upgrade Hero # chuyển pin của Hero ở mọi trang lên phiên bản mới nhất
|
|
1004
1068
|
sb site components upgrade Hero --to 3 --dry-run
|
|
1069
|
+
sb site components preview Hero --props '{"title":"Hi"}' # build ở máy, render thử một lần trên nền tảng
|
|
1070
|
+
sb site components list # từng component: phiên bản mới nhất, số phiên bản, kích thước, ngày tạo
|
|
1071
|
+
sb site components list --json # như trên, dạng JSON
|
|
1072
|
+
sb site components delete Hero 2 # xoá một phiên bản (hỏi trước; ngoài terminal cần --yes)
|
|
1073
|
+
sb site components delete Hero 2 --dry-run # cho biết sẽ xoá gì, không xoá gì
|
|
1005
1074
|
```
|
|
1006
1075
|
|
|
1007
1076
|
Code component là một component React (Preact) trong `components/<Name>.tsx`, xuất props dưới dạng
|
|
@@ -1023,8 +1092,40 @@ trong trình duyệt — component nào cũng kèm JavaScript của nó.
|
|
|
1023
1092
|
phiên bản có thật. Không có gì trên trang tự dịch chuyển.
|
|
1024
1093
|
- **Nâng cấp là sửa cục bộ.** `sb site components upgrade <Name> [--to <n>]` ghi lại các pin trong
|
|
1025
1094
|
`design/` (trang, section dùng chung, overlay), nêu tên prop mà phiên bản mới không còn nhận,
|
|
1026
|
-
và không gửi gì. Xem diff, rồi `sb site push` lưu bản nháp.
|
|
1027
|
-
|
|
1095
|
+
và không gửi gì. Xem diff, rồi `sb site push` lưu bản nháp.
|
|
1096
|
+
- **`html`, `clientUrl` và `hydrateProps` thuộc về nền tảng.** Markup đã render của component, địa chỉ
|
|
1097
|
+
bundle chạy trên trình duyệt và bộ props đã làm sạch dùng để hydrate là dữ liệu suy ra: mỗi lần lưu, nền tảng giữ nguyên chúng nếu pin và props
|
|
1098
|
+
không đổi, còn không thì render lại, bất kể file ghi gì. Vì vậy file trang không bao giờ chứa
|
|
1099
|
+
chúng — `sb site pull` không ghi ra, và file nào vẫn còn (do `sb` bản cũ kéo về, hoặc tự gõ tay)
|
|
1100
|
+
sẽ được đọc như thể không có: `sb site push` và `sb doctor` nêu tên file, node và khoá
|
|
1101
|
+
(`` `html` on code-component cc_1 is rendered by the platform; your edit is ignored. ``). File
|
|
1102
|
+
bạn chưa sửa kể từ khi `sb` bản cũ kéo về sẽ được ghi lại không có chúng ở lần `sb site pull`
|
|
1103
|
+
kế tiếp. Host Next (`sb site next`) xem trước từng component bằng markup nền tảng đã lưu; component
|
|
1104
|
+
nào bạn đổi pin hoặc props ở máy, có lần render gần nhất trên nền tảng bị lỗi, hoặc không đọc được
|
|
1105
|
+
bản nháp đã lưu, sẽ hiện không có markup đó — báo một lần trên console và nêu tên ở mọi response
|
|
1106
|
+
trong `x-sbuilder-unrendered` — cho tới khi `sb site push` render nó.
|
|
1107
|
+
- **Xem trước.** `sb site components preview <Name> [--props <json|@file>] [--json]` build
|
|
1108
|
+
`components/<Name>.tsx` ở máy, đúng như push, rồi để nền tảng render nó một lần trong cùng sandbox
|
|
1109
|
+
(`POST /api/v1/code-components/preview`): lệnh in ra HTML mà một lần lưu trang sẽ lưu
|
|
1110
|
+
(`--json`: `{"html": …}`). Prop có trong schema mà `--props` bỏ trống thì lấy giá trị mặc định; prop
|
|
1111
|
+
lạ và prop `css` bị bỏ, như khi lưu trang. Không tải lên gì và không trang nào đổi. Bị từ chối —
|
|
1112
|
+
`bundle_rejected` kèm lỗi của chính sandbox, `invalid_props` nêu tên prop, `css_prop_name`, vượt giới
|
|
1113
|
+
hạn kích thước — thì in mã lỗi và thông báo rồi thoát 1, chính là thứ agent đọc để sửa component.
|
|
1114
|
+
Nền tảng đang bận (429 / 503) thì in `Retry-After` và thoát 1; không tự thử lại. `--dry-run` chỉ build.
|
|
1115
|
+
Cần API key (`wbk_…`, `pages.write`).
|
|
1116
|
+
- **Cho AI agent.** `sb site init` và `sb site components init` ghi
|
|
1117
|
+
`.claude/skills/sbuilder-components/SKILL.md` và `AGENTS.md` chỉ tới nó: khi nào nên dùng code
|
|
1118
|
+
component (ưu tiên element có sẵn), các luật về props và sandbox ở trên, dòng `<CodeComponent …/>`
|
|
1119
|
+
và vòng làm việc này. Component ví dụ trong đó được build, và đoạn trang được parse, bởi chính test của CLI.
|
|
1120
|
+
- **Liệt kê và xoá.** `sb site components list [--json]` cho thấy mọi component trên nền tảng kèm
|
|
1121
|
+
phiên bản mới nhất, số phiên bản, kích thước SSR và client của từng phiên bản, ngày tạo, và các
|
|
1122
|
+
phiên bản mà file trong repo này đang pin (bản nháp và trang đang chạy của nền tảng thì không
|
|
1123
|
+
liệt kê). `sb site components delete <Name> <version> [--yes]` xoá một phiên bản: lệnh hỏi
|
|
1124
|
+
trước, và ngoài terminal thì cần `--yes`; `--dry-run` không xoá gì: lệnh chỉ đọc phiên bản, nên phiên bản không tồn tại sẽ được nêu tên, còn việc có trang nào đang pin nó thì chỉ lệnh xoá thật mới biết.
|
|
1125
|
+
Khi còn bản nháp hay trang đang chạy, section dùng
|
|
1126
|
+
chung hoặc overlay nào dùng phiên bản đó, nền tảng từ chối: các trang nó nêu được in ra và mã
|
|
1127
|
+
thoát là 1. **Số phiên bản đã xoá không bao giờ được dùng lại** — lần tải lên sau nhận số mới,
|
|
1128
|
+
nên một pin không bao giờ đổi sang trỏ vào mã khác. Xoá cần API key (`wbk_…`, `pages.write`).
|
|
1028
1129
|
- **Giới hạn.** SSR bundle 512 KiB, client bundle 256 KiB (báo tên ngay ở máy trước khi tải lên),
|
|
1029
1130
|
một giây để render, đồng hồ đứng yên ở 2000-01-01 và `Math.random` có seed (`fetch`, timer và
|
|
1030
1131
|
`crypto` ném lỗi),
|
|
@@ -1063,7 +1164,8 @@ nhiều khả năng muốn đang tắt; chỉ `fail` mới làm exit code là `1
|
|
|
1063
1164
|
| `scope:write` | các quyền ghi — **không thử** (GET không thử được việc ghi); nó nói mỗi quyền chặn gì | không bao giờ |
|
|
1064
1165
|
| `site` | `sb.json` nêu một site mà key hoặc login này tới được, và `.sb-site.json` cùng site đó | không có `siteId`, JSON hỏng, manifest của site khác, site không đọc được |
|
|
1065
1166
|
| `manifest` | `.sb-site.json`: mọi đường dẫn nằm trong thư mục của loại đó dưới `design/`, không có symlink | đường dẫn ngoài `design/`, symlink (file thiếu chỉ là `warn`) |
|
|
1066
|
-
| `files` | mọi file dưới `design/` đều parse được | có file không parse: in `file:line:col` |
|
|
1167
|
+
| `files` | mọi file dưới `design/` đều parse được | có file không parse: in `file:line:col`. Cảnh báo nêu file vẫn còn `html` hoặc `clientUrl` của code component (thuộc về nền tảng; bị bỏ qua) |
|
|
1168
|
+
| `agents` | trong repo site, mọi file agent (`AGENTS.md`, các skill, cấu hình MCP, workflow CI) đúng là văn bản bản sb này ghi, hoặc là bản bạn đã giữ | có file khác hoặc thiếu (cảnh báo): `sb site agents --refresh` |
|
|
1067
1169
|
| `components:build` | các file `components/<Name>.tsx` có `schema` dạng literal, và `esbuild` đã cài trong repo (chỉ tìm `package.json` của nó — không bao giờ nạp). Tĩnh: **không chạy mã nào của repo** | `schema` của một file không phải literal, liên kết tượng trưng, thiếu esbuild. Với `--build` thêm: component không build được hoặc vượt giới hạn kích thước |
|
|
1068
1170
|
| `components:pins` | mọi `<CodeComponent version={n}>` trong `design/` nêu một phiên bản mà nền tảng có (GET) | có cái không có (`sb site components upgrade`, hoặc `sb site push` để tải lên) |
|
|
1069
1171
|
| `domain` | tên miền chính của cửa hàng so với `SB_PUBLIC_URL`, và việc địa chỉ có sẵn chuyển hướng | chúng khác nhau; địa chỉ có sẵn chuyển hướng về deployment của bạn (vòng lặp — sửa: Manage → Domains → Default address → *Serve this site directly*) |
|