@sbuilder/cli 0.7.0 → 0.8.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.
@@ -0,0 +1,326 @@
1
+ import { execFileSync } from 'node:child_process';
2
+ import { mkdir, readdir, writeFile } from 'node:fs/promises';
3
+ import { basename, dirname, join } from 'node:path';
4
+ import { authedFetch } from './auth.js';
5
+ import { pull as codePull } from './code.js';
6
+ import { DEFAULT_API } from './login.js';
7
+ import { pull, SiteRefused, SITE_MANIFEST, SITE_UNAUTHORIZED } from './site.js';
8
+ /** The CLI version the generated files pin, so CI never drifts onto a major it was not written for. */
9
+ export const CLI_RANGE = '0.8';
10
+ const CLI = `@sbuilder/cli@${CLI_RANGE}`;
11
+ /** Scopes a key never carries: each means "this human's account", and the gateway refuses them on a key. */
12
+ const ACCOUNT_LEVEL = ['member.manage', 'role.manage', 'site.update', 'site.export'];
13
+ export const WORKFLOW = `# Two-way sync with Store Builder. Written by \`sb site init\`.
14
+ #
15
+ # push to main -> edited pages and code files are saved as DRAFTS
16
+ # every 30 min -> what was edited in the editor is pulled and committed
17
+ # Run workflow -> tick "publish" to make every page live
18
+ #
19
+ # Needs one secret: SB_TOKEN = an API key (wbk_...). \`sb site init --github\` sets
20
+ # it; otherwise copy it from .env. Point at another platform with the SB_API
21
+ # repository variable.
22
+ name: sbuilder sync
23
+
24
+ on:
25
+ push:
26
+ branches: [main]
27
+ paths: ['design/**', 'code/**']
28
+ schedule:
29
+ - cron: '*/30 * * * *'
30
+ workflow_dispatch:
31
+ inputs:
32
+ publish:
33
+ description: 'Publish every page after syncing (makes the drafts live)'
34
+ type: boolean
35
+ default: false
36
+
37
+ permissions:
38
+ contents: write
39
+
40
+ concurrency: sbuilder-sync
41
+
42
+ jobs:
43
+ sync:
44
+ runs-on: ubuntu-latest
45
+ env:
46
+ SB_TOKEN: \${{ secrets.SB_TOKEN }}
47
+ SB_API: \${{ vars.SB_API }}
48
+ steps:
49
+ - uses: actions/checkout@v4
50
+ - uses: actions/setup-node@v4
51
+ with:
52
+ node-version: 22
53
+ - name: Save edits as drafts
54
+ if: github.event_name == 'push'
55
+ run: |
56
+ npx -y ${CLI} site push
57
+ npx -y ${CLI} code push --dir code
58
+ - name: Pull what was edited in the editor
59
+ run: |
60
+ npx -y ${CLI} site pull
61
+ npx -y ${CLI} code pull --dir code
62
+ - name: Commit
63
+ run: |
64
+ git add -A design code ${SITE_MANIFEST}
65
+ if git diff --cached --quiet; then exit 0; fi
66
+ git -c user.name=sbuilder-sync -c user.email=41898282+github-actions[bot]@users.noreply.github.com \\
67
+ commit -m "sync: edits made in the editor"
68
+ git push
69
+ - name: Publish
70
+ if: github.event_name == 'workflow_dispatch' && inputs.publish
71
+ run: npx -y ${CLI} site publish --all
72
+ `;
73
+ const MCP_SERVER = { command: 'npx', args: ['-y', CLI, 'mcp'] };
74
+ /** One server, three clients' file shapes. */
75
+ export const MCP_FILES = {
76
+ '.mcp.json': JSON.stringify({ mcpServers: { sbuilder: MCP_SERVER } }, null, 2) + '\n',
77
+ '.cursor/mcp.json': JSON.stringify({ mcpServers: { sbuilder: MCP_SERVER } }, null, 2) + '\n',
78
+ '.vscode/mcp.json': JSON.stringify({ servers: { sbuilder: { type: 'stdio', ...MCP_SERVER } } }, null, 2) + '\n',
79
+ };
80
+ export function agentsMd(site) {
81
+ return `# Working on ${site.name}
82
+
83
+ This repo is the Store Builder site **${site.name}**${site.publicUrl ? ` (${site.publicUrl})` : ''}.
84
+ You build it through the \`sbuilder\` MCP tools, which edit the site's DRAFTS on the platform.
85
+ Nothing you do here is live until the owner publishes.
86
+
87
+ ## Build with the tools, not by hand
88
+
89
+ 1. \`sb_connect\`, then \`sb_page_list\` / \`sb_page_open\` the page you are working on.
90
+ 2. Native elements first: \`sb_catalog_search\` for what the section needs, \`sb_traits_for\`
91
+ for its settings, then \`sb_add\` ONE nested spec per section. Use \`custom-code\` only for a
92
+ gap you can name that no element covers.
93
+ 3. Bind real data with \`sb_bind\` (products, collections, forms) — never type a product's
94
+ name or price into a text block.
95
+ 4. After every section: \`sb_look\` to see it on desktop AND mobile, \`sb_review\` to catch
96
+ problems. Fix what you see before moving on.
97
+ 5. When a page is done, run \`npx ${CLI} site pull\` so the result lands in \`design/pages/\`,
98
+ and tell the owner what changed (they review it as a git diff).
99
+
100
+ Writes default to \`dry_run: true\`; pass \`dry_run: false\` once you mean it.
101
+
102
+ ## Rules
103
+
104
+ - **Never publish unless the owner asks.** Publishing is \`npx ${CLI} site publish <file>\`
105
+ (or \`--all\`), and it makes pages live for every visitor.
106
+ - **Ask for real facts** — phone, address, prices, opening hours. Do not invent them.
107
+ - Write page copy in the site's language, with full diacritics for Vietnamese.
108
+ - Do not delete pages; say which one you would remove and why.
109
+ - **An installed app's block belongs to the app.** Its root carries \`appBlockId\`; never edit inside
110
+ it — the platform discards those edits and \`site push\` refuses them. Change only its
111
+ \`appBlockValues\` (the settings the app declares), move it, or remove it whole.
112
+ - \`design/pages/*.page.tsx\` is each page as source — one tag per element, its settings as
113
+ props. You may edit it directly (text, settings, moving or adding elements; a new element needs
114
+ no \`id\`), then \`npx ${CLI} site push\` and \`sb_look\` to see it. Keep every existing \`id\`.
115
+ Page files hold data only: no logic, no variables, no text between tags (use \`text="…"\`).
116
+ - \`code/\` holds Code Dock files (CSS/JS injected into pages): \`npx ${CLI} code push --dir code\`.
117
+
118
+ ## Files
119
+
120
+ | Path | What it is |
121
+ | --- | --- |
122
+ | \`design/pages/*.page.tsx\` | One page's draft, as source |
123
+ | \`code/\` | Code Dock files |
124
+ | \`${SITE_MANIFEST}\`, \`code/.sb-code.json\` | What was last synced — how edits on both sides are told apart |
125
+ | \`.env\` | This repo's API key. Never commit it, never print it |
126
+ `;
127
+ }
128
+ function readme(site) {
129
+ return `# ${site.name}
130
+
131
+ The Store Builder site **${site.name}**${site.publicUrl ? ` (${site.publicUrl})` : ''}, as a repo.
132
+
133
+ ## Build it with an AI agent
134
+
135
+ Open this folder in **Claude Code**, **Cursor** or **VS Code** and ask for what you want:
136
+
137
+ claude "Làm trang chủ bán trà: ảnh lớn, bảng giá, form đặt hàng"
138
+
139
+ The agent uses the Store Builder tools (approve the \`sbuilder\` server the first time), builds on
140
+ the site's drafts, looks at what it built, and pulls the result into this repo. Nothing goes live
141
+ until you publish.
142
+
143
+ ## Commands
144
+
145
+ npx @sbuilder/cli site pull # take what was edited in the editor
146
+ npx @sbuilder/cli site push # save your edits as drafts
147
+ npx @sbuilder/cli site publish --all # make every page live
148
+ npx @sbuilder/cli code pull --dir code # Code Dock files (code push to send them back)
149
+
150
+ A page edited on both sides is never overwritten silently: the command names it and stops;
151
+ \`--force\` picks a side. New pages are created in the editor (or by the agent), then pulled.
152
+
153
+ | Path | What it is |
154
+ | --- | --- |
155
+ | \`design/pages/*.page.tsx\` | One page's draft as source — edit it, push it |
156
+ | \`code/\` | Code Dock files (CSS/JS injected into pages) |
157
+ | \`${SITE_MANIFEST}\` | What was last synced — commit it |
158
+ | \`.env\` | This repo's API key — never committed |
159
+ | \`AGENTS.md\` | How an AI agent should work here |
160
+ `;
161
+ }
162
+ async function getJSON(o, url, init = {}) {
163
+ const res = await authedFetch(url, init, o.token);
164
+ if (res.status === 401)
165
+ throw new SiteRefused(SITE_UNAUTHORIZED);
166
+ if (!res.ok) {
167
+ let msg = `HTTP ${res.status}`;
168
+ try {
169
+ msg = (await res.json()).error ?? msg;
170
+ }
171
+ catch {
172
+ // keep the status
173
+ }
174
+ throw new SiteRefused(`${new URL(url).pathname} failed: ${msg}`);
175
+ }
176
+ return (await res.json());
177
+ }
178
+ const post = (body) => ({
179
+ method: 'POST',
180
+ headers: { 'Content-Type': 'application/json' },
181
+ body: JSON.stringify(body),
182
+ });
183
+ async function chooseSite(o) {
184
+ if (o.create) {
185
+ const { site } = await getJSON(o, `${o.api}/api/sites`, post({ name: o.create }));
186
+ return site;
187
+ }
188
+ const { sites } = await getJSON(o, `${o.api}/api/sites`);
189
+ if (o.site) {
190
+ const s = sites.find((x) => x.id === o.site || x.slug === o.site);
191
+ if (!s)
192
+ throw new SiteRefused(`no site "${o.site}" among the sites this login can see.`);
193
+ return s;
194
+ }
195
+ if (sites.length === 0)
196
+ throw new SiteRefused('this login has no sites yet — run sb init and choose a new website.');
197
+ if (sites.length === 1)
198
+ return sites[0];
199
+ if (o.pick)
200
+ return o.pick(sites);
201
+ throw new SiteRefused('Which site? Pass --site <id>:\n' + sites.map((s) => ` ${s.id} ${s.name}`).join('\n'));
202
+ }
203
+ /** An API key for this repo, with every content scope the account may delegate. */
204
+ async function mintKey(o, siteId) {
205
+ const { scopes } = await getJSON(o, `${o.api}/api/permissions`);
206
+ const wanted = (scopes ?? []).filter((s) => !ACCOUNT_LEVEL.includes(s));
207
+ const { secret } = await getJSON(o, `${o.api}/api/sites/${encodeURIComponent(siteId)}/api-keys`, post({ name: `AI agent · ${basename(o.dir)}`, scopes: wanted }));
208
+ if (typeof secret !== 'string' || !secret.startsWith('wbk_'))
209
+ throw new SiteRefused('the server answered without a key');
210
+ return secret;
211
+ }
212
+ const envLine = (k, v) => `${k}=${/[\s#"']/.test(v) ? JSON.stringify(v) : v}`;
213
+ export async function initSite(o) {
214
+ const log = o.log ?? console.log;
215
+ const warn = o.warn ?? log;
216
+ if (!o.token)
217
+ throw new SiteRefused(SITE_UNAUTHORIZED);
218
+ const isKey = typeof o.token === 'string' && o.token.startsWith('wbk_');
219
+ if (isKey && !o.site) {
220
+ throw new SiteRefused('An API key does not list sites; pass --site <id> (the key’s own site).');
221
+ }
222
+ const existing = await readdir(o.dir).catch(() => []);
223
+ const clash = ['sb.json', SITE_MANIFEST, 'design'].filter((f) => existing.includes(f));
224
+ if (clash.length) {
225
+ throw new SiteRefused(`${o.dir} already has ${clash.join(', ')} — run sb site pull there instead.`);
226
+ }
227
+ const site = isKey
228
+ ? { id: o.site, name: basename(o.dir), slug: '' }
229
+ : await chooseSite(o);
230
+ if (o.create)
231
+ log(`Created the site ${site.name}${site.publicUrl ? ` — ${site.publicUrl}` : ''}`);
232
+ // The key is what makes the repo usable by an agent and by CI. Failing to mint
233
+ // one is not failing the repo: say so, and the session still works locally.
234
+ let key = isKey ? o.token : '';
235
+ if (!key) {
236
+ try {
237
+ key = await mintKey(o, site.id);
238
+ log(`Created an API key "AI agent · ${basename(o.dir)}" for this repo (in .env; revoke it in Settings -> API keys).`);
239
+ }
240
+ catch (err) {
241
+ warn(` ! no API key was created (${err.message}). Agents and CI need one: ` +
242
+ 'create it in Settings -> API keys and put SB_TOKEN=… in .env.');
243
+ }
244
+ }
245
+ const env = [
246
+ "# This repo's Store Builder key. NEVER commit this file.",
247
+ ...(key ? [envLine('SB_TOKEN', key)] : ['# SB_TOKEN=wbk_…']),
248
+ envLine('SB_SITE', site.id),
249
+ envLine('SB_SITE_NAME', site.name),
250
+ ...(site.publicUrl ? [envLine('SB_STOREFRONT', site.publicUrl)] : []),
251
+ ...(o.api !== DEFAULT_API ? [envLine('SB_API', o.api)] : []),
252
+ ].join('\n');
253
+ const files = {
254
+ 'sb.json': JSON.stringify({ siteId: site.id }, null, 2) + '\n',
255
+ '.gitignore': 'node_modules\n.env\n',
256
+ '.env': env + '\n',
257
+ 'README.md': readme(site),
258
+ 'AGENTS.md': agentsMd(site),
259
+ 'CLAUDE.md': '@AGENTS.md\n',
260
+ '.github/workflows/sbuilder.yml': WORKFLOW,
261
+ ...MCP_FILES,
262
+ };
263
+ for (const [f, text] of Object.entries(files)) {
264
+ await mkdir(dirname(join(o.dir, f)), { recursive: true });
265
+ await writeFile(join(o.dir, f), text, { encoding: 'utf8', mode: f === '.env' ? 0o600 : 0o644 });
266
+ }
267
+ log(`Pulling ${site.name} into ${o.dir}`);
268
+ const code = await pull({ api: o.api, token: o.token, dir: o.dir, site: site.id, log, warn });
269
+ try {
270
+ await codePull({
271
+ api: o.api,
272
+ token: o.token,
273
+ dir: join(o.dir, 'code'),
274
+ site: site.id,
275
+ cwd: o.dir,
276
+ log,
277
+ warn,
278
+ });
279
+ }
280
+ catch (err) {
281
+ warn(` ! Code Dock files were not pulled (${err.message}); run sb code pull --dir code later.`);
282
+ }
283
+ if (o.github) {
284
+ const run = o.run ??
285
+ ((cmd, args, cwd, input) => void execFileSync(cmd, args, {
286
+ cwd,
287
+ input,
288
+ stdio: [input === undefined ? 'inherit' : 'pipe', 'inherit', 'inherit'],
289
+ }));
290
+ run('git', ['init', '-b', 'main'], o.dir);
291
+ run('git', ['add', '-A'], o.dir);
292
+ run('git', ['commit', '-m', `${site.name}, from Store Builder`], o.dir);
293
+ run('gh', ['repo', 'create', basename(o.dir), '--private', '--source', '.', '--push'], o.dir);
294
+ if (key) {
295
+ // On stdin, never argv: a secret on a command line is readable by every process.
296
+ run('gh', ['secret', 'set', 'SB_TOKEN'], o.dir, key);
297
+ log('On GitHub, with the SB_TOKEN secret set — the sync workflow is live.');
298
+ }
299
+ else {
300
+ log('On GitHub. Last step — the workflow needs a key: gh secret set SB_TOKEN');
301
+ }
302
+ }
303
+ return { code, site, keyed: !!key };
304
+ }
305
+ /** The words after init: how to start building, on whatever this machine has. */
306
+ export function nextSteps(dir, github) {
307
+ const out = ['', 'Next:', ` cd ${dir}`];
308
+ out.push(' claude "Làm trang chủ bán trà: ảnh lớn, bảng giá, form đặt hàng"');
309
+ out.push(' (or open the folder in Cursor / VS Code — the Store Builder tools are set up)');
310
+ if (!github) {
311
+ out.push('', 'To keep it on GitHub, synced both ways:');
312
+ out.push(' git init -b main && git add -A && git commit -m "From Store Builder"');
313
+ out.push(' gh repo create --private --source . --push');
314
+ out.push(' gh secret set SB_TOKEN # paste the SB_TOKEN value from .env');
315
+ out.push(' (next time, sb site init <dir> --github does all of this)');
316
+ }
317
+ return out;
318
+ }
319
+ /** The prompt an agent starts with when the site was described in the menu. */
320
+ export function buildPrompt(description) {
321
+ return (`Build this website on Store Builder: "${description}". ` +
322
+ 'Follow AGENTS.md — build each section with the sbuilder tools, look at it on desktop and ' +
323
+ 'mobile, fix what you see, then pull the result into this repo. Ask me for any real facts ' +
324
+ '(phone, address, prices) you need. Do not publish.');
325
+ }
326
+ //# sourceMappingURL=siteinit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"siteinit.js","sourceRoot":"","sources":["../../src/siteinit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEpD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAmDhF,uGAAuG;AACvG,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,CAAC;AAC/B,MAAM,GAAG,GAAG,iBAAiB,SAAS,EAAE,CAAC;AAEzC,4GAA4G;AAC5G,MAAM,aAAa,GAAG,CAAC,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC;AAErF,MAAM,CAAC,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBA2CL,GAAG;mBACH,GAAG;;;mBAGH,GAAG;mBACH,GAAG;;;mCAGa,aAAa;;;;;;;sBAO1B,GAAG;CACxB,CAAC;AAEF,MAAM,UAAU,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC;AAEhE,8CAA8C;AAC9C,MAAM,CAAC,MAAM,SAAS,GAA2B;IAC/C,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE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