@plitzi/cli 0.37.2 → 0.37.4

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,31 +1,39 @@
1
1
  {
2
2
  "name": "@plitzi/cli",
3
- "version": "0.37.2",
3
+ "version": "0.37.4",
4
4
  "license": "AGPL-3.0",
5
- "description": "Command line for Plitzi: scaffold a server that renders a space you own.",
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": [
7
- "dist"
7
+ "dist",
8
+ "skills"
8
9
  ],
9
10
  "type": "module",
10
11
  "bin": {
11
12
  "plitzi": "./dist/index.js"
12
13
  },
14
+ "exports": {
15
+ "./skills/*": "./skills/*",
16
+ "./package.json": "./package.json"
17
+ },
13
18
  "repository": {
14
19
  "type": "https",
15
20
  "url": "https://github.com/plitzi/plitzi-workspace.git"
16
21
  },
17
22
  "sideEffects": false,
18
23
  "dependencies": {
19
- "@plitzi/sdk-authoring": "0.37.2",
24
+ "@plitzi/sdk-authoring": "0.37.4",
20
25
  "chalk": "^6.0.0",
21
- "commander": "^15.0.0"
26
+ "commander": "^15.0.0",
27
+ "esbuild": "^0.28.2",
28
+ "fflate": "^0.8.3"
22
29
  },
23
30
  "devDependencies": {
31
+ "@plitzi/sdk-shared": "0.37.4",
24
32
  "@types/node": "^26.6.2",
25
33
  "eslint": "^9.39.5",
26
34
  "eslint-plugin-import": "^2.32.0",
27
35
  "typescript": "^6.0.3",
28
- "vite": "^8.3.0",
36
+ "vite": "^8.3.1",
29
37
  "vitest": "^5.0.1"
30
38
  },
31
39
  "scripts": {
@@ -0,0 +1,154 @@
1
+ ---
2
+ name: plitzi-cli
3
+ description: >-
4
+ Use the Plitzi command line (@plitzi/cli, `plitzi …` or `npx @plitzi/cli …`) instead of hand-writing what it
5
+ generates: scaffold a project that renders a space, add elements of your own (plugins) to it, create a plugin package,
6
+ build a plugin into the module + manifest + zip the platform takes, sign in to upload and install it on a space, and
7
+ edit a space's own server code (its functions) in the project. Use whenever the task is to start a Plitzi project,
8
+ create or change a plugin/custom element, pack, upload or install one, pull/push/try a space's functions, or work out
9
+ which space the CLI is connected to.
10
+ ---
11
+
12
+ # The Plitzi CLI
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.**
17
+
18
+ ```bash
19
+ npx @plitzi/cli create my-site # a project that renders a space
20
+ npx @plitzi/cli add plugin seat-picker legend # elements of your own, in the project you are in
21
+ npx @plitzi/cli create seat-picker --plugin # a plugin package any space can load
22
+ npx @plitzi/cli pack plugin # a plugin built, and zipped the way the builder takes it
23
+ npx @plitzi/cli upload plugin # that zip, on the space you work in, and installed there
24
+ npx @plitzi/cli whoami # who the CLI is signed in as, and the space it works in
25
+ npx @plitzi/cli functions pull # the space's functions (its own server code) into functions/
26
+ npx @plitzi/cli functions push # functions/ back as the space's draft, built and checked
27
+ npx @plitzi/cli functions try feed.read --params '{"limit":3}' # one task of the saved draft, in the sandbox
28
+ npx @plitzi/cli functions dev feed.read --watch # the same, from functions/, on this machine
29
+ ```
30
+
31
+ `plitzi --help` and `plitzi <command> --help` list every flag; what follows is what the help does not say.
32
+
33
+ ## Running it as an agent
34
+
35
+ - **`create` never decides for the person.** Three choices shape a project — package manager, `--mode`
36
+ (`server`: SSR + RSC on a Node tier, `client`: browser only) and `--source` (`local`: the space lives in the project,
37
+ `cloud`: it lives in Plitzi). With nobody at the terminal it writes NOTHING and prints each missing choice as a
38
+ question: ask the user, then run again with their answers as flags. `--yes` does not get around it — it only takes
39
+ the defaults for a person at a terminal. Do not guess the answers.
40
+ - **Signing in happens in the browser.** `login`, `space` and a first `upload` open one; the person completes it (MFA
41
+ and social sign-in included — the CLI never sees a password). Tell them a browser tab is waiting, and wait.
42
+ - **One space at a time.** Everything goes to the space `whoami` names; `plitzi space` switches it. No command takes a
43
+ space as a flag, so check `whoami` before an upload.
44
+ - **`--no-install`** writes the files without installing, **`--force`** writes into a directory that has work in it.
45
+
46
+ ## Projects (`create`)
47
+
48
+ | | `--source local` | `--source cloud` |
49
+ | --- | --- | --- |
50
+ | `--mode server` | A page server of your own, rendering the space in `src/space.ts`. No account | Your page server, rendering the live space from Plitzi (secret self-hosting key in `.env`) |
51
+ | `--mode client` | Vite + the SDK in the browser, no server, no account | The SDK fetches the space with the public render key |
52
+
53
+ What a project gives you, so you use it rather than rebuild it:
54
+
55
+ | Script | What it is for |
56
+ | --- | --- |
57
+ | `start` | serve it — in client mode Vite, which hot-replaces on save |
58
+ | `start:dev` | server mode: the server, restarted on save |
59
+ | `author` | author `src/space.ts` and print every warning — the check after each change (local projects) |
60
+ | `shot -- /path --width 390 --scheme dark` | a picture of one page |
61
+ | `visual` | a browser asserts every element the space names is visible |
62
+ | `typecheck`, `lint`, `format` | before calling a change done |
63
+
64
+ The space itself is written with `@plitzi/sdk-authoring` — see the `plitzi-authoring` skill, which `create` copies into
65
+ `.claude/skills/` beside this one.
66
+
67
+ ## Elements of your own (`add plugin`)
68
+
69
+ A plugin is a React component the space renders — a map, a chart, a seat picker: whatever is not text in a box. **Never
70
+ start one from a blank file**: `add plugin <name>` writes it in the shape the platform, the builder and the linter all
71
+ read.
72
+
73
+ ```bash
74
+ plitzi add plugin seat-picker # one; asks what the builder calls it and what it is for
75
+ plitzi add plugin seat-picker legend # several at once
76
+ plitzi add plugin seat-picker --title "Seat Picker" --description "Pick a seat from a venue map"
77
+ ```
78
+
79
+ Each is a folder (`src/plugins/SeatPicker/` in a project `create` wrote):
80
+
81
+ | File | What it holds |
82
+ | --- | --- |
83
+ | `SeatPicker.tsx` | the component. Its props ARE the element's attributes; render through `RootElement` |
84
+ | `declaration.ts` | its `type`, the `triggers` (events) it fires, the `callbacks` (actions) it answers, its default attributes — data only |
85
+ | `Settings.tsx` | its panel in the builder |
86
+ | `index.ts` | the three put together |
87
+
88
+ - **Registered by itself**: every folder of `src/plugins` is, under its name in camelCase (`SeatPicker` → `seatPicker`).
89
+ Elsewhere the command prints the line that registers it (for `render()`, `<PlitziSdk>` or a page server).
90
+ - **Host it** with `custom({ renderType: 'seatPicker', … })` in `src/space.ts` — or a Custom element in the builder.
91
+ - **Checked like a built-in element**: `add plugin` also lists its declaration in `src/plugins/declarations.ts`, which
92
+ every place the project authors the space hands to `authorSpace(space, { plugins: declarations })`. Flows on its
93
+ events, steps to its actions and its attributes are refused when wrong; `declaredTrigger(declaration, 'onPick')` and
94
+ `declaredCallback(declaration, 'reset', { on: 'seats' })` build those steps, typed from the declaration. A plugin
95
+ written by hand is added to that list with its `declaration.ts`.
96
+ - **A new event or action** is declared in `declaration.ts` and registered by the component FROM there — never only
97
+ in the component, or neither the builder nor the linter knows it exists.
98
+ - A name that is a built-in type (`button`, `form`) is refused: a space could not tell the two apart.
99
+
100
+ ## Plugin packages (`create --plugin`)
101
+
102
+ Elements any space can load, published on their own, with a Vite preview to write them in:
103
+
104
+ ```bash
105
+ plitzi create seat-picker --plugin
106
+ plitzi create packages/seat-picker --plugin --name @acme/plitzi-plugin-seat-picker --elements legend,price-tag
107
+ ```
108
+
109
+ Its scripts: `start` (the elements inside a space, hot-replaced), `visual`, `typecheck`, `lint`. Add more elements with
110
+ `add plugin` from inside it — they are listed in `src/elements.ts` and `src/declarations.ts`, which the package
111
+ publishes from. A package's element is authored as a TYPE of its own: `defineElement<SeatPickerAttributes>(declaration)`.
112
+
113
+ ## Building and shipping (`pack plugin`, `upload plugin`)
114
+
115
+ ```bash
116
+ plitzi pack plugin # in a plugin package: every element
117
+ plitzi pack plugin src/plugins/SeatPicker # an element of a project; several folders → one plugin, the first its main
118
+ plitzi upload plugin # the zip pack left, onto the space whoami names, installed there
119
+ ```
120
+
121
+ `pack` writes one ES module (React and the SDK kept out — the page provides them), `plugin-manifest.json` from the
122
+ declarations with integrity hashes, and the zip the builder takes under Resources. `upload` checks the manifest,
123
+ sends the zip to one of the space's CDNs (`--cdn`) and installs it — a plugin already there moves to the new version with
124
+ its settings kept. `--plugin-version` sets the version the manifest carries.
125
+
126
+ A self-hosted page server does not need `pack`: it compiles a plugin from its source
127
+ (`plugins: { seatPicker: { js: 'src/plugins/SeatPicker/index.ts', action: 'compile' } }` in `createServer`).
128
+
129
+ ## A space's functions (`functions`)
130
+
131
+ A space's own server code — TypeScript tasks its actions run as steps, and routes under `/api/` — lives in the space;
132
+ `functions/` in a project is a **working copy** of it. The contract (`defineFunctions`, `ctx`) and every rule are in
133
+ `docs/en/functions.md` of the workspace; what matters for the CLI:
134
+
135
+ - **Pull before you edit, push when done.** `pull` refuses to overwrite what is not pushed (`--force` throws it
136
+ away); `push` refuses when the space changed since the pull — someone saved in the builder. Then: keep your changes
137
+ aside, `pull`, apply them again, `push`. Never `--force` over somebody else's work to get past it.
138
+ - **A push is checked, not just stored.** A problem comes back as `functions/<file>:<line> <message>` and nothing is
139
+ saved — fix it and push again. `index.ts` must default-export `defineFunctions({ … })`; files import each other by
140
+ relative path and `@plitzi/sdk-server/functions`, nothing else.
141
+ - **`try` runs the saved draft for real** (its fetches and writes happen). `dev` runs `functions/` on this machine with
142
+ the project's own `@plitzi/sdk-server` — `npm install -D @plitzi/sdk-server isolated-vm core-js` first — and sends
143
+ nothing to the space; `PLITZI_FUNCTIONS_CREDENTIALS='{"stripe":{"apiKey":"…"}}'` gives it credentials to name.
144
+ - **The live site runs what the space was last published with.** A push changes the draft; publishing is the person's.
145
+
146
+ ## When something does not work
147
+
148
+ | What you see | What it is |
149
+ | --- | --- |
150
+ | `create` printed questions and wrote nothing | nobody answered the three choices — ask the user, pass them as flags |
151
+ | An element renders "Custom Component … Not Found" | the `renderType` names no registered plugin — check the folder name's camelCase |
152
+ | A flow on the plugin's event is refused, or never runs | the event is not in `declaration.ts`, or the plugin is missing from `src/plugins/declarations.ts` |
153
+ | `upload` opens a browser | there is no session, or no space chosen — the person completes it there |
154
+ | The upload went to the wrong space | `plitzi space` chooses another; check `whoami` first |