@plitzi/cli 0.38.7 → 0.38.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plitzi/cli",
3
- "version": "0.38.7",
3
+ "version": "0.38.8",
4
4
  "license": "AGPL-3.0",
5
5
  "description": "Command line for Plitzi: scaffold a project that renders a space, a plugin package, or an element of your own.",
6
6
  "files": [
@@ -21,14 +21,14 @@
21
21
  },
22
22
  "sideEffects": false,
23
23
  "dependencies": {
24
- "@plitzi/sdk-authoring": "0.38.7",
24
+ "@plitzi/sdk-authoring": "0.38.8",
25
25
  "chalk": "^6.0.1",
26
26
  "commander": "^15.0.0",
27
27
  "esbuild": "^0.28.2",
28
28
  "fflate": "^0.8.3"
29
29
  },
30
30
  "devDependencies": {
31
- "@plitzi/sdk-shared": "0.38.7",
31
+ "@plitzi/sdk-shared": "0.38.8",
32
32
  "@types/node": "^26.6.4",
33
33
  "eslint": "^9.39.5",
34
34
  "eslint-plugin-import": "^2.32.0",
@@ -4,211 +4,50 @@ description: >-
4
4
  Use the Plitzi command line (@plitzi/cli, `plitzi …` or `npx @plitzi/cli …`) instead of hand-writing what it
5
5
  generates: scaffold a project that renders a space, add plugins to it or build a plugin package, pack, upload and
6
6
  install one, edit a space's functions, take a space on Plitzi out as a self-hosted project and back (`create --from`,
7
- `pull`, `push`), and check a project (`doctor`) or how its space's source is written (`lint`). Use whenever the task is
7
+ `space pull`, `space push`), and check a project (`doctor`) or how its space's source is written (`space lint`). Use whenever the task is
8
8
  to start a Plitzi project, create or change a plugin, pack, upload or install one, pull/push/try a space's functions,
9
9
  move a space to a server of its own and back, or work out which space the CLI is connected to.
10
10
  ---
11
11
 
12
12
  # The Plitzi CLI
13
13
 
14
- The CLI writes what an agent would otherwise get subtly wrong by hand: a project's server, bundler, lint and visual
15
- test wired together; a plugin's four files in the shape Plitzi's own elements use; a manifest with integrity hashes;
16
- a signed-in upload. **Reach for it before writing any of those yourself.**
14
+ The CLI writes what an agent would otherwise get subtly wrong by hand: a project's server, bundler, lint and visual test
15
+ wired together; a plugin's files in the shape Plitzi's own elements use; a signed-in upload. **Reach for it before
16
+ writing any of those yourself.** `plitzi <command> --help` lists every flag.
17
17
 
18
18
  ```bash
19
- npx @plitzi/cli create my-site # a project that renders a space (--template blank | catalog)
20
- npx @plitzi/cli create my-board --from pizarra # a space on Plitzi, as a project that serves it alone
21
- npx @plitzi/cli pull # that project brought up to date with its space
22
- npx @plitzi/cli push # its changes back as the draft (or: push space functions)
23
- npx @plitzi/cli add plugin seat-picker legend # elements of your own, in the project you are in
24
- npx @plitzi/cli create seat-picker --plugin # a plugin package any space can load
25
- npx @plitzi/cli pack plugin # a plugin built, and zipped the way the builder takes it
26
- npx @plitzi/cli upload plugin # that zip, on the space you work in, and installed there
27
- npx @plitzi/cli whoami # who the CLI is signed in as, and the space it works in
28
- npx @plitzi/cli data describe src/data/x.json # a JSON file's fields, types and one row
29
- npx @plitzi/cli upgrade # the project up to this CLI: files, package.json, skills, renames (--write)
30
- npx @plitzi/cli explain navigate # what a name means: element, step, trigger, code, helper (bindTemplate, motion)
31
- npx @plitzi/cli functions pull # the space's functions (its own server code) into src/functions/
32
- npx @plitzi/cli functions push # src/functions/ back as the space's draft, built and checked
33
- npx @plitzi/cli functions try feed.read --params '{"limit":3}' # one task of the saved draft, in the sandbox
34
- npx @plitzi/cli functions dev feed.read --watch # the same, from src/functions/, on this machine
19
+ npx plitzi element where hero-cta # where the code writes an element: file:line and the call
20
+ npx plitzi element edit hero-cta --set content="Hi" # an attribute written there, checked
21
+ npx plitzi element remove ent-trust # an element taken out, with what only it used
22
+ npx plitzi element move ent-faq --before ent-pricing # an element put elsewhere among its siblings
23
+ npx plitzi verify # left passing? author, lints, types, format, pages
24
+ npx plitzi page check -- /about --width 1440,390 # whether a page is whole, in text
25
+ npx plitzi explain navigate # what a name means: element, step, code, any export
26
+ npx plitzi doctor # whether the project is whole; --fix the simple parts
27
+ npx plitzi upgrade # the project up to this CLI (--write)
28
+ npx plitzi feedback # a report to Plitzi, for the person to send as a link
35
29
  ```
36
30
 
37
- `plitzi <command> --help` lists every flag; what follows is what the help does not say.
38
-
39
31
  ## Running it as an agent
40
32
 
41
- - **Which check.** The space as a document: `npm run author`. How its source is written: `npm run lint:space`. A
42
- rendered page: `check`. The project around them (layout, packages, configs, imports, plugins, data): `doctor`,
43
- before `push`; `--fix` repairs the simple ones (an older project: `npx @plitzi/cli@latest doctor --fix`).
44
-
45
- - **Reporting to Plitzi: `feedback`.** It writes the report's page and says how to fill and publish it; give the
46
- person the link.
47
-
48
- - **After the SDK moves, `upgrade`.** It shows the CLI's files, scripts, versions, skills and renamed names as they
49
- should be. `--write` replaces what nobody changed, merges `package.json` and installs; a file you changed comes as a
50
- diff — `--take <file>` once read.
51
-
52
- - **`create` never decides for the person.** Three choices shape a project — package manager, `--mode`
53
- (`server`: SSR + RSC on a Node tier, `client`: browser only) and `--source` (`local`: the space lives in the project,
54
- `cloud`: it lives in Plitzi). With nobody at the terminal it writes NOTHING and prints each missing choice as a
55
- question: ask the user, then run again with their answers as flags. `--yes` only takes the defaults for a person at
56
- a terminal; never guess the answers.
57
- - **Signing in happens in the browser.** `login`, `space` and a first `upload` open one; the person completes it (MFA
58
- and social sign-in included — the CLI never sees a password). Tell them a tab is waiting, and wait.
59
- - **One space at a time.** Everything goes to the space `whoami` names; `plitzi space` switches it. No command takes a
60
- space as a flag, so check `whoami --json` (`{ api, user, space }`) before an upload.
61
- - **Read stdout, exit code and stderr apart.** The answer is on stdout (`--json`: one object, one line); errors and
62
- sign-in prompts are on stderr; exit 1 means it did not do what was asked, or a check found something. A bad flag
63
- value is refused with what it takes: read it, do not drop the flag.
64
-
65
- ## The Plitzi MCP or this CLI
66
-
67
- Where the space lives decides which one an agent uses — the two never take turns on one space.
68
-
69
- | The space | Use |
70
- | --- | --- |
71
- | In a project, written in code (`src/space/`, `--source local`) | this CLI and `@plitzi/sdk-authoring`. No account and no MCP |
72
- | On Plitzi — edited in the builder, with collaborators, published from there | the Plitzi MCP server: it reads and edits the live space, previews a page and checks every edit with the same linter |
73
- | On Plitzi, and wanted in code from now on | `create --from <space>`, then `pull` and `push` keep both in step |
74
-
75
- The MCP needs a signed-in account; when nobody can give one, do not wait on it: a `--source local` project needs
76
- neither.
77
-
78
- ## Projects (`create`)
79
-
80
- | | `--source local` | `--source cloud` |
81
- | --- | --- | --- |
82
- | `--mode server` | A page server of your own, rendering the space in `src/space/`. No account | Your page server, rendering the live space from Plitzi (secret self-hosting key in `.env`) |
83
- | `--mode client` | Vite + the SDK in the browser, no server, no account | The SDK fetches the space with the public render key |
84
-
85
- What a project gives you, so you use it rather than rebuild it:
86
-
87
- | Script | What it is for |
88
- | --- | --- |
89
- | `start` | serve it — in client mode Vite, which hot-replaces on save. The server prints only what goes wrong; `-- --verbose` adds every request |
90
- | `start:dev` | server mode: restarted on a save to its code; a plugin is swapped in the open page. Options in `src/config/serverOptions.ts`, actions in `src/actions/`; `plitzi/` is the CLI's, never edit it |
91
- | `author` | author `src/space/`: every problem at once (file:line, what to change), then the suggestions (`[suggest]`: a shorter way to the same page, the most elements saved first); `-- --json` for a tool |
92
- | `lint:space` | how `src/space/` is written, at file:line, and authoring's suggestions; `-- --max-warnings 0`. On purpose: `// plitzi-lint-disable-next-line <code> -- why` (a suggestion: `quiet` on its element) |
93
- | `npx plitzi fix` | what `author` reports that has one fix, as a diff of your source; `--write` writes it, formatted, and keeps it only if the space then authors with it gone and nothing new |
94
- | `check -- /path --width 1440,390` | whether a page is whole, in text: elements on screen, overflow, console, refused requests, failed flows, a binding its data lacks; `--state`, `--element <id>`: what it holds; `--ssr`: SSR misses; `--as <user>`; `--json` |
95
- | `npx plitzi import <url>` | a page the user owns, as a start: `tokens.ts`, `outline.ts` (blocks and layout per breakpoint), lists as `data/*.json`, screenshots, `IMPORT.md`. Never the words. **Only when the user asks.** A site not on this machine needs `--account` (their Plitzi account, its domain verified on a space): ask first |
96
- | `shot -- /path --width 390 --scheme dark` | a picture of one page — `--clip <element>` one element, `--scroll-to <element>` / `--viewport` the screen there, `--frames 4` what moves, `--compare <url>` what differs from another site, by section and by text |
97
- | `visual` | a browser asserts every element the space names is visible |
98
- | `typecheck`, `lint`, `format` | before calling a change done |
99
-
100
- **Which port.** `start` takes 8080, or the next free one — printed, and written to `tmp/dev-server.json` for `check`,
101
- `shot` and `visual`. `PORT` chooses one (a taken one is then an error). `/health` answers with the space's name.
102
-
103
- Data with no backend, server mode: `src/data/*.json`, never served — a provider with `runtime: 'server'` and `query:
104
- '/data/x.json'` reads it on the server. Client mode: `public/data/`, fetched — public. Learn a file's fields with
105
- `data describe`, never by reading it.
106
-
107
- **`public/` is on the internet**: never a secret there. `tmp/`, `state/` (its `kv`) ignored; `.plitzi/` committed.
108
- `--dry-run` on a command that writes or sends says what it would do, and does none of it.
109
-
110
- A local space starts as a tour of the platform with a plugin of the project's own; **`--template blank`** as tokens, a
111
- layout and one empty page — for a project about to be a specific site; **`--template catalog`** as a small shop
112
- (layout, card component, data in `src/data`, a filtered list, a page per product), a file per part — the one to read
113
- when unsure how a whole site is put together.
114
-
115
- The space itself is written with `@plitzi/sdk-authoring` — see the `plitzi-authoring` skill, which `create` copies into
116
- `.claude/skills/` beside this one.
117
-
118
- ## A space on Plitzi, as a project (`create --from`, `pull`)
119
-
120
- Taking a space out of Plitzi as a server project of its own, and keeping it in step: read
121
- [reference/from-space.md](reference/from-space.md) when the task names `--from` or `pull`.
122
-
123
- ## Elements of your own (`add plugin`)
124
-
125
- A plugin is a React component the space renders — a map, a chart, a seat picker: whatever is not text in a box. **Never
126
- start one from a blank file**: `add plugin <name>` writes it in the shape the platform, the builder and the linter all
127
- read.
128
-
129
- ```bash
130
- plitzi add plugin seat-picker # one; asks what the builder calls it and what it is for
131
- plitzi add plugin seat-picker legend # several at once
132
- plitzi add plugin ticker --prop interval:number=5000 --prop paused:boolean --trigger onTick:count --callback reset --headless
133
- ```
134
-
135
- **Say its shape and it is written in it**: `--prop name:type=default` (string, number, boolean; `list`/`json` for data
136
- a binding fills) per attribute — typed, bindable, with a control in its panel; `--trigger onTick:count` per event and
137
- what a flow reads, fired with its `use<Name>Events()` hook; `--callback reset` per action a flow calls; `--headless`
138
- for one with nothing to see. Without them it writes a counter showing the three ways an element talks to a space.
139
-
140
- Each is a folder (`src/plugins/SeatPicker/` in a project `create` wrote):
141
-
142
- | File | What it holds |
143
- | --- | --- |
144
- | `SeatPicker.tsx` | the component. Its props ARE the element's attributes; render through `RootElement` |
145
- | `declaration.ts` | its `type`, the `triggers` (events) it fires, the `callbacks` (actions) it answers, its default attributes — data only |
146
- | `Settings.tsx` | its panel in the builder |
147
- | `index.ts` | the three put together |
148
-
149
- - **Registered by itself**: every folder of `src/plugins` is, under its name in camelCase (`SeatPicker` → `seatPicker`).
150
- Elsewhere the command prints the line that registers it (for `render()`, `<PlitziSdk>` or a page server).
151
- - **Host it** with `custom({ renderType: 'seatPicker', … })` in `src/space/` — or a Custom element in the builder.
152
- - **Checked like a built-in element**: its folder's `declaration.ts` is found by itself and handed to
153
- `authorSpace(space, { plugins })`: flows on its events, steps to its actions and its attributes are
154
- refused when wrong; `declaredTrigger(declaration, 'onPick')` and `declaredCallback(declaration, 'reset', { on: 'seats' })`
155
- build them typed. A plugin written by hand is added to that list.
156
- - **A new event or action** is declared in `declaration.ts` and registered by the component FROM there — never only
157
- in the component, or neither the builder nor the linter knows it exists.
158
- - A name that is a built-in type (`button`, `form`) is refused: a space could not tell the two apart.
159
- - **A server half** (`--server`): `functions/index.ts` in its folder — routes under `/fn/plugins/<type>/`
160
- (`usePluginRoute`), steps `<type>.<action>`, its own `kv`, none of the space's credentials.
161
-
162
- ## Plugin packages (`create --plugin`)
163
-
164
- Elements any space can load, published on their own, with a Vite preview to write them in:
165
-
166
- ```bash
167
- plitzi create seat-picker --plugin
168
- plitzi create packages/seat-picker --plugin --name @acme/plitzi-plugin-seat-picker --elements legend,price-tag
169
- ```
170
-
171
- Its scripts: `start` (the elements inside a space, hot-replaced), `visual`, `typecheck`, `lint`. Add more elements with
172
- `add plugin` from inside it — they are listed in `src/elements.ts` and `src/declarations.ts`, which the package
173
- publishes from. A package's element is authored as a TYPE of its own: `defineElement<SeatPickerAttributes>(declaration)`.
174
-
175
- ## Building and shipping (`pack plugin`, `upload plugin`)
176
-
177
- ```bash
178
- plitzi pack plugin # in a plugin package: every element
179
- plitzi pack plugin src/plugins/SeatPicker # an element of a project; several folders → one plugin, the first its main
180
- plitzi upload plugin # the zip pack left, onto the space whoami names, installed there
181
- ```
182
-
183
- `pack` writes one ES module (React and the SDK kept out — the page provides them), `plugin-manifest.json` from the
184
- declarations with integrity hashes, and the zip the builder takes under Resources. `upload` checks the manifest,
185
- sends the zip to one of the space's CDNs (`--cdn`) and installs it — a plugin already there moves to the new version with
186
- its settings kept. `--plugin-version` sets the version the manifest carries. The plugin's source — every file it
187
- imports, followed from its entry — is kept beside it on the space (`runtime push` does the same for a runtime), which
188
- is what `create --from` brings back; `plitzi pack source` writes what would be kept to a file, to look at.
189
-
190
- A self-hosted page server does not need `pack`: it compiles a plugin from its source (`action: 'compile'`).
191
-
192
- The same server decides its own say over the space's **feature flags**: `createServer({ flags: { newCheckout: true } })`
193
- (or a function of `{ spaceId, environment }` when it serves several). It overrides what the space declares — only for
194
- flags the space declares — and is overridden by the SDK's `flags` prop and a tester's dev tools. Declaring the flags
195
- themselves is the space's (`flags` in the spec; see the authoring skill's feature flags).
196
-
197
- ## Server code (`functions`, `runtime`)
198
-
199
- A space's own server code, edited in `src/functions/` (`pull`, `push`, `try`, `dev`) or run as its runtime
200
- (`src/runtime/`, `add runtime`, `runtime push`): read [reference/functions.md](reference/functions.md) for either.
201
-
202
-
203
- ## When something does not work
204
-
205
- | What you see | What it is |
206
- | --- | --- |
207
- | `create` printed questions and wrote nothing | nobody answered the three choices — ask the user, pass them as flags |
208
- | `start` says the port is in use | `PORT` is set to a taken port — unset it to take the next free one, or choose another |
209
- | A page that is not this project's, or `shot` refuses the port | another server answers there — `curl 127.0.0.1:<port>/health` names it; `tmp/dev-server.json` has this project's port |
210
- | "Custom Component … Not Found", or a flow on a plugin's event never runs | `doctor` names the folder whose type or declaration is off |
211
- | "not laid out as Plitzi reads it" | each misplaced part, with its fix; `doctor --fix` |
212
- | `upload` opens a browser | there is no session, or no space chosen — the person completes it there |
213
- | The upload went to the wrong space | `plitzi space` chooses another; check `whoami` first |
214
- | `pull` wrote nothing and named files | they changed here and on the space — set your changes aside and pull again, or `--force` |
33
+ - **Which check.** All of it before you finish: `verify` — only what fails is printed. The space alone: `npm run
34
+ author`; a page: `page check`. The project around them: `doctor`, before `space push`.
35
+ - **`create` never decides for the person.** With nobody at the terminal it writes nothing and prints each choice as a
36
+ question: ask the user, then run again with their answers as flags. Never guess them.
37
+ - **Signing in happens in the browser** (`login`, `space use`, a first `plugin upload`): tell the person a tab is waiting.
38
+ - **One space at a time** — the one `whoami --json` names; `plitzi space use` switches it.
39
+ - **Read stdout, exit code and stderr apart.** The answer is on stdout (`--json`: one line); exit 1 means it did not do
40
+ what was asked. A refusal says what to change: change it — the same refusal twice says to stop and ask.
41
+
42
+ **The MCP or this CLI.** A space written in code (`src/space/`) is this CLI's, with no account. One kept on Plitzi —
43
+ edited in the builder — is the Plitzi MCP's. Never both on one space.
44
+
45
+ ## What to read
46
+
47
+ | The task | Read |
48
+ | -------------------------------------------------------------------------- | ----------------------------------------------- |
49
+ | Start a project, its modes, scripts and port | [projects](reference/projects.md) |
50
+ | An element of your own, a plugin package, packing and uploading one | [plugins](reference/plugins.md) |
51
+ | A space on Plitzi as a project, and back (`create --from`, `space pull`, `space push`) | [from-space](reference/from-space.md) |
52
+ | The space's own server code (`functions`, `runtime`) | [functions](reference/functions.md) |
53
+ | Something does not work | [troubleshooting](reference/troubleshooting.md) |
@@ -1,4 +1,4 @@
1
- # A space on Plitzi, as a project (`create --from`, `pull`, `push`)
1
+ # A space on Plitzi, as a project (`create --from`, `space pull`, `space push`)
2
2
 
3
3
  `create --from <space>` (its permanent URL or id) writes a server project holding everything the space is made of, and
4
4
  serving it with nothing of Plitzi's — neither its servers nor its CDN:
@@ -17,19 +17,19 @@ pinned) says otherwise. Read the report it prints: a
17
17
  plugin or runtime uploaded before Plitzi kept sources comes across built only (`vendor/`), and a space with visitor
18
18
  roles needs sign-in of its own (the report says how).
19
19
 
20
- `pull` brings the project up to date: what changed on the space alone is written, what changed here alone is kept,
20
+ `space pull` brings the project up to date: what changed on the space alone is written, what changed here alone is kept,
21
21
  and when one file changed on both it writes **nothing** and names them — keep your changes aside and pull again, or
22
22
  `--force` to take the space's copy. It never touches `.env`, and only adds to `package.json`. What the project was given
23
23
  is recorded in `.plitzi/space.json`: commit it. It follows the version the project was made from; `pull --environment
24
24
  … --revision …` moves it to another, `--revision latest` lets go of a pin.
25
25
 
26
- `push` is the way back: what changed in the project, as the space's **draft** — publishing stays the builder's. At a
26
+ `space push` is the way back: what changed in the project, as the space's **draft** — publishing stays the builder's. At a
27
27
  terminal it lists the parts with what changed ticked; otherwise it sends what changed, or the parts named:
28
- `push space functions` (`space`, `functions`, `data`, `runtime`, `plugins`, `files`). Plugins and the files of
28
+ `space push space functions` (`space`, `functions`, `data`, `runtime`, `plugins`, `files`). Plugins and the files of
29
29
  `public/assets/` go up first (each file at the same path under the space's `assets/`), then the functions, the data, the
30
30
  runtime, and the pages, actions and connectors last. Only `public/assets/` reaches the space's CDN: put a file the space
31
31
  names there, never elsewhere in `public/`. It is refused when the draft was edited in the builder since the
32
32
  project last had it — pull first, or `--force` to replace it — and a project that never had the space may only take a
33
33
  space nobody has worked on without `--force`. It pushes to the space the CLI is connected to, which must be the one
34
- the project came from, and records what it sent in `.plitzi/space.json`, so `pull` works afterwards — on a project that
34
+ the project came from, and records what it sent in `.plitzi/space.json`, so `space pull` works afterwards — on a project that
35
35
  started on its own too.
@@ -4,9 +4,9 @@ A space's own server code — TypeScript tasks its actions run as steps, and rou
4
4
  `src/functions/` in a project is a **working copy** of it. The contract (`defineFunctions`, `ctx`) is typed in
5
5
  `@plitzi/sdk-server/functions`, whose `.d.ts` documents every field; what matters for the CLI:
6
6
 
7
- - **Pull before you edit, push when done.** `pull` refuses to overwrite what is not pushed (`--force` throws it
8
- away); `push` refuses when the space changed since the pull — someone saved in the builder. Then: keep your changes
9
- aside, `pull`, apply them again, `push`. Never `--force` over somebody else's work to get past it.
7
+ - **Pull before you edit, push when done.** `functions pull` refuses to overwrite what is not pushed (`--force` throws it
8
+ away); `functions push` refuses when the space changed since the pull — someone saved in the builder. Then: keep your
9
+ changes aside, `functions pull`, apply them again, `functions push`. Never `--force` over somebody else's work to get past it.
10
10
  - **A push is checked, not just stored.** A problem comes back as `src/functions/<file>:<line> <message>` and nothing is
11
11
  saved — fix it and push again. `index.ts` must default-export `defineFunctions({ … })`; files import each other by
12
12
  relative path and `@plitzi/sdk-server/functions`, nothing else. `src/data/` is read with `ctx.data('x.json')`, never
@@ -21,7 +21,7 @@ A space's own server code — TypeScript tasks its actions run as steps, and rou
21
21
  ## A space's runtime (`runtime`)
22
22
 
23
23
  What a function cannot be — Node packages, a connection held open, state across requests — is the space's **runtime**:
24
- `src/runtime/index.ts` (`plitzi add runtime`), default-exporting `defineRuntime` from `@plitzi/sdk-server/runtime` (its
24
+ `src/runtime/index.ts` (`plitzi runtime add`), default-exporting `defineRuntime` from `@plitzi/sdk-server/runtime` (its
25
25
  `.d.ts` documents it). The project's server runs it as Plitzi does, so try it with `npm start` before pushing.
26
26
 
27
27
  - `runtime push` packs it (`--entry` for another file) as the draft's runtime; publishing deploys it. Its source goes
@@ -30,4 +30,3 @@ What a function cannot be — Node packages, a connection held open, state acros
30
30
  reads the value from stdin (`printf %s "$V" | …`), never echo it in a command line; `vars unset NAME` removes one.
31
31
  - `runtime size small|medium|large`, `stop`, `start` — the draft's unless `--environment` names a published one.
32
32
  - It needs a plan that includes runtimes and a private bucket on the space's CDN; a refusal says which is missing.
33
-
@@ -0,0 +1,75 @@
1
+ # Elements of your own, and plugin packages
2
+
3
+ ## Elements of your own (`plugin add`)
4
+
5
+ A plugin is a React component the space renders — a map, a chart, a seat picker: whatever is not text in a box. **Never
6
+ start one from a blank file**: `add plugin <name>` writes it in the shape the platform, the builder and the linter all
7
+ read.
8
+
9
+ ```bash
10
+ plitzi plugin add seat-picker # one; asks what the builder calls it and what it is for
11
+ plitzi plugin add seat-picker legend # several at once
12
+ plitzi plugin add ticker --prop interval:number=5000 --prop paused:boolean --trigger onTick:count --callback reset --headless
13
+ ```
14
+
15
+ **Say its shape and it is written in it**: `--prop name:type=default` (string, number, boolean; `list`/`json` for data
16
+ a binding fills) per attribute — typed, bindable, with a control in its panel; `--trigger onTick:count` per event and
17
+ what a flow reads, fired with its `use<Name>Events()` hook; `--callback reset` per action a flow calls; `--headless`
18
+ for one with nothing to see. Without them it writes a counter showing the three ways an element talks to a space.
19
+
20
+ Each is a folder (`src/plugins/SeatPicker/` in a project `create` wrote):
21
+
22
+ | File | What it holds |
23
+ | --- | --- |
24
+ | `SeatPicker.tsx` | the component. Its props ARE the element's attributes; render through `RootElement` |
25
+ | `declaration.ts` | its `type`, the `triggers` (events) it fires, the `callbacks` (actions) it answers, its default attributes — data only |
26
+ | `Settings.tsx` | its panel in the builder |
27
+ | `index.ts` | the three put together |
28
+
29
+ - **Registered by itself**: every folder of `src/plugins` is, under its name in camelCase (`SeatPicker` → `seatPicker`).
30
+ Elsewhere the command prints the line that registers it (for `render()`, `<PlitziSdk>` or a page server).
31
+ - **Host it** with `custom({ renderType: 'seatPicker', … })` in `src/space/` — or a Custom element in the builder.
32
+ - **Checked like a built-in element**: its folder's `declaration.ts` is found by itself and handed to
33
+ `authorSpace(space, { plugins })`: flows on its events, steps to its actions and its attributes are
34
+ refused when wrong; `declaredTrigger(declaration, 'onPick')` and `declaredCallback(declaration, 'reset', { on: 'seats' })`
35
+ build them typed. A plugin written by hand is added to that list.
36
+ - **A new event or action** is declared in `declaration.ts` and registered by the component FROM there — never only
37
+ in the component, or neither the builder nor the linter knows it exists.
38
+ - A name that is a built-in type (`button`, `form`) is refused: a space could not tell the two apart.
39
+ - **A server half** (`--server`): `functions/index.ts` in its folder — routes under `/fn/plugins/<type>/`
40
+ (`usePluginRoute`), steps `<type>.<action>`, its own `kv`, none of the space's credentials.
41
+
42
+ ## Plugin packages (`create --plugin`)
43
+
44
+ Elements any space can load, published on their own, with a Vite preview to write them in:
45
+
46
+ ```bash
47
+ plitzi create seat-picker --plugin
48
+ plitzi create packages/seat-picker --plugin --name @acme/plitzi-plugin-seat-picker --elements legend,price-tag
49
+ ```
50
+
51
+ Its scripts: `start` (the elements inside a space, hot-replaced), `visual`, `typecheck`, `lint`. Add more elements with
52
+ `plugin add` from inside it — they are listed in `src/elements.ts` and `src/declarations.ts`, which the package
53
+ publishes from. A package's element is authored as a TYPE of its own: `defineElement<SeatPickerAttributes>(declaration)`.
54
+
55
+ ## Building and shipping (`plugin pack`, `plugin upload`)
56
+
57
+ ```bash
58
+ plitzi plugin pack # in a plugin package: every element
59
+ plitzi plugin pack src/plugins/SeatPicker # an element of a project; several folders → one plugin, the first its main
60
+ plitzi plugin upload # the zip pack left, onto the space whoami names, installed there
61
+ ```
62
+
63
+ `pack` writes one ES module (React and the SDK kept out — the page provides them), `plugin-manifest.json` from the
64
+ declarations with integrity hashes, and the zip the builder takes under Resources. `upload` checks the manifest,
65
+ sends the zip to one of the space's CDNs (`--cdn`) and installs it — a plugin already there moves to the new version with
66
+ its settings kept. `--plugin-version` sets the version the manifest carries. The plugin's source — every file it
67
+ imports, followed from its entry — is kept beside it on the space (`runtime push` does the same for a runtime), which
68
+ is what `create --from` brings back; `plitzi source pack` writes what would be kept to a file, to look at.
69
+
70
+ A self-hosted page server does not need `pack`: it compiles a plugin from its source (`action: 'compile'`).
71
+
72
+ The same server decides its own say over the space's **feature flags**: `createServer({ flags: { newCheckout: true } })`
73
+ (or a function of `{ spaceId, environment }` when it serves several). It overrides what the space declares — only for
74
+ flags the space declares — and is overridden by the SDK's `flags` prop and a tester's dev tools. Declaring the flags
75
+ themselves is the space's (`flags` in the spec; see the authoring skill's feature flags).
@@ -0,0 +1,42 @@
1
+ # Projects
2
+
3
+ ## `create`
4
+
5
+ | | `--source local` | `--source cloud` |
6
+ | --- | --- | --- |
7
+ | `--mode server` | A page server of your own, rendering the space in `src/space/`. No account | Your page server, rendering the live space from Plitzi (secret self-hosting key in `.env`) |
8
+ | `--mode client` | Vite + the SDK in the browser, no server, no account | The SDK fetches the space with the public render key |
9
+
10
+ What a project gives you, so you use it rather than rebuild it:
11
+
12
+ | Script | What it is for |
13
+ | --- | --- |
14
+ | `start` | serve it — in client mode Vite, which hot-replaces on save. The server prints only what goes wrong; `-- --verbose` adds every request |
15
+ | `start:dev` | server mode: restarted on a save to its code; a plugin is swapped in the open page. Options in `src/config/serverOptions.ts`, actions in `src/actions/`; `plitzi/` is the CLI's, never edit it |
16
+ | `author` | author `src/space/`: every problem at once (file:line, what to change), then the suggestions (`[suggest]`: a shorter way to the same page, the most elements saved first); `-- --json` for a tool |
17
+ | `lint:space` | how `src/space/` is written, at file:line, and authoring's suggestions; `-- --max-warnings 0`. On purpose: `// plitzi-lint-disable-next-line <code> -- why` (a suggestion: `quiet` on its element) |
18
+ | `npx plitzi space fix` | what `author` reports that has one fix, as a diff of your source; `--write` writes it, formatted, and keeps it only if the space then authors with it gone and nothing new |
19
+ | `npx plitzi element where <id\|class\|words>` | where the code writes an element: file:line and the call — edit it there, not the files around it. `npx plitzi element edit <id> --set content="…"` writes an attribute in it, `remove <id>` takes it out, `move <id> --before <id>` reorders it — each checked |
20
+ | `check -- /path --width 1440,390` | whether a page is whole, in text: elements on screen, overflow, console, refused requests, failed flows, a binding its data lacks; `--state`, `--element <id>`: what it holds; `--ssr`: SSR misses; `--as <user>`; `--json` |
21
+ | `npx plitzi page import <url>` | a page the user owns, as a start: tokens, its blocks' layout, lists as `data/*.json` — never the words. **Only when the user asks**; a site not on this machine needs `--account`: ask first |
22
+ | `shot -- /path --width 390 --scheme dark` | a picture of one page — `--clip <element>` one element, `--frames 4` what moves, `--compare <url>` what differs from another site |
23
+ | `visual` | a browser asserts every element the space names is visible |
24
+ | `typecheck`, `lint`, `format` | before calling a change done |
25
+
26
+ **Which port.** `start` takes 8080, or the next free one — printed, and written to `tmp/dev-server.json` for `check`,
27
+ `shot` and `visual`. `PORT` chooses one (a taken one is then an error). `/health` answers with the space's name.
28
+
29
+ Data with no backend, server mode: `src/data/*.json`, never served — a provider with `runtime: 'server'` and `query:
30
+ '/data/x.json'` reads it on the server. Client mode: `public/data/`, fetched — public. Learn a file's fields with
31
+ `data describe`, never by reading it.
32
+
33
+ **`public/` is on the internet**: never a secret there. `tmp/`, `state/` (its `kv`) ignored; `.plitzi/` committed.
34
+ `--dry-run` on a command that writes or sends says what it would do, and does none of it.
35
+
36
+ A local space starts as a tour of the platform with a plugin of the project's own; **`--template blank`** as tokens, a
37
+ layout and one empty page — for a project about to be a specific site; **`--template catalog`** as a small shop
38
+ (layout, card component, data in `src/data`, a filtered list, a page per product), a file per part — the one to read
39
+ when unsure how a whole site is put together.
40
+
41
+ The space itself is written with `@plitzi/sdk-authoring` — see the `plitzi-authoring` skill, which `create` copies into
42
+ `.claude/skills/` beside this one.
@@ -0,0 +1,12 @@
1
+ # When something does not work
2
+
3
+ | What you see | What it is |
4
+ | --- | --- |
5
+ | `create` printed questions and wrote nothing | nobody answered the three choices — ask the user, pass them as flags |
6
+ | `start` says the port is in use | `PORT` is set to a taken port — unset it to take the next free one, or choose another |
7
+ | A page that is not this project's, or `page shot` refuses the port | another server answers there — `curl 127.0.0.1:<port>/health` names it; `tmp/dev-server.json` has this project's port |
8
+ | "Custom Component … Not Found", or a flow on a plugin's event never runs | `doctor` names the folder whose type or declaration is off |
9
+ | "not laid out as Plitzi reads it" | each misplaced part, with its fix; `doctor --fix` |
10
+ | `upload` opens a browser | there is no session, or no space chosen — the person completes it there |
11
+ | The upload went to the wrong space | `plitzi space use` chooses another; check `whoami` first |
12
+ | `space pull` wrote nothing and named files | they changed here and on the space — set your changes aside and pull again, or `--force` |