create-restforge-skills 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -34,8 +34,10 @@ restforge-skills/
34
34
  ├── README.md ← this file
35
35
  ├── package.json ← npm package: create-restforge-skills
36
36
  ├── bump-and-publish.bat ← version bump + npm publish
37
+ ├── sync-to-plugin.bat ← mirror the skill into the Claude Code plugin
37
38
  ├── cli/
38
- │ └── index.js ← installer that copies the skill into each client
39
+ │ ├── index.js ← installer that copies the skill into each client
40
+ │ └── mcp.js ← merges the MCP server into each client config
39
41
  ├── docs/ ← internal docs, NOT published (excluded from npm files)
40
42
  └── skills/
41
43
  └── restforge/
@@ -43,6 +45,17 @@ restforge-skills/
43
45
  └── references/ ← progressive-disclosure reference material
44
46
  ```
45
47
 
48
+ ## Single source of truth
49
+
50
+ `skills/restforge/` here is the **one** authoritative copy of the skill. Two
51
+ distribution channels consume it — do not edit the skill anywhere else:
52
+
53
+ - **This package** (`create-restforge-skills`) — published to npm; cross-client.
54
+ - **The Claude Code plugin** (`../packages/restforge-plugins`) — its
55
+ `skills/restforge-skills/` folder is a **generated mirror**. After editing the
56
+ canonical skill, run `sync-to-plugin.bat` to propagate, then commit the plugin
57
+ repo. Hand-edits to the plugin's skill copy are overwritten on the next sync.
58
+
46
59
  ## Install
47
60
 
48
61
  One command. It detects your installed clients (Claude Code, Cursor), copies the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-restforge-skills",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Install the RESTForge Agent Skill into Claude Code, Cursor, and other skills-compatible clients.",
5
5
  "type": "commonjs",
6
6
  "bin": {
@@ -4,7 +4,8 @@ description: >
4
4
  RESTForge end-to-end workflow — use for any task involving RESTForge: SDF
5
5
  (Schema Definition File), RDF (Resource Definition File), UDF (UI Definition
6
6
  File), dbschema, defineModel, codegen, payload, generate endpoint, generate
7
- dashboard, generate frontend, migrate schema, setup project, or design-to-SDF
7
+ dashboard, generate frontend, migrate schema, setup project, add authentication
8
+ (project auth backend, embedded rfx_auth frontend auth), or design-to-SDF
8
9
  (deriving a schema from an HTML mockup, screenshot, image, or UI design). Also
9
10
  active for the codegen_*, designer_*, setup_*, runtime_* MCP tools and the
10
11
  @restforgejs/platform / @restforgejs/mcp-server packages. Defines the canonical
@@ -51,6 +52,24 @@ The platform exposes its capabilities as MCP tools grouped by domain: `health_*`
51
52
 
52
53
  ---
53
54
 
55
+ ## Preflight (run before any RESTForge task)
56
+
57
+ Verify readiness before planning or producing anything:
58
+
59
+ 1. **Are the RESTForge MCP tools present?** If `codegen_*` / `designer_*` are not
60
+ in your available tools, the MCP server is **not active**. Stop and tell the
61
+ user to register the RESTForge MCP server and restart the client. Do **not**
62
+ finish the task by hand-reading the bundled `references/` — that bypasses the
63
+ generator and yields slower, non-deterministic output.
64
+ 2. **Backend work** → confirm the project and config are ready with
65
+ `runtime_detect_project`, then the `setup_validate_config` gate.
66
+ 3. **Frontend work** → the Designer tools pre-check that `restforge-designer` is
67
+ on PATH; if it is missing, surface that before proceeding.
68
+
69
+ If a prerequisite is missing, report it as the next step — do not improvise around it.
70
+
71
+ ---
72
+
54
73
  ## Backend Pipeline (canonical)
55
74
 
56
75
  This is the canonical (golden) path. For state-dependent choices see Decision
@@ -134,12 +153,9 @@ earlier steps that already succeeded.
134
153
  Verify the server is running and endpoints are reachable.
135
154
  ```
136
155
 
137
- Two hard checkpoints in this track, both expanded under Guardrails:
138
-
139
- - **Step 5 is a gate**, not a suggestion. No `codegen_*` call before
140
- `setup_validate_config` passes.
141
- - **Step 17 is where the agent stops.** The agent never starts, stops, or
142
- restarts the server itself; it only generates the launcher.
156
+ Two hard checkpoints (see Guardrails): **step 5** is a gate — no `codegen_*` call
157
+ before `setup_validate_config` passes; **step 17** is where the agent stops (it
158
+ generates the launcher, never runs the server).
143
159
 
144
160
  ---
145
161
 
@@ -191,12 +207,9 @@ designer_scaffold_plugin → [develop plugin templates]
191
207
  → designer_generate (test generation with the custom plugin)
192
208
  ```
193
209
 
194
- Two checkpoints in this track, mirrored in Guardrails:
195
-
196
- - **Step 5 is a gate.** Never call `designer_generate` on an unvalidated UDF
197
- payload — generation on an invalid payload produces incomplete or broken output.
198
- - **Step 7 is where the agent stops.** The agent generates files; it does not
199
- serve, open, or deploy the frontend.
210
+ Two checkpoints (see Guardrails): **step 5** is a gate — never `designer_generate`
211
+ an unvalidated payload; **step 7** is where the agent stops (generates files, does
212
+ not serve or deploy).
200
213
 
201
214
  Licensing note: the Designer tools (`designer_preview_files`, `designer_generate`,
202
215
  etc.) do **not** require a RESTForge license, unlike the `codegen_*`, `runtime_*`,
@@ -204,6 +217,55 @@ and `setup_validate_config` tools on the backend track.
204
217
 
205
218
  ---
206
219
 
220
+ ## Auth Extension
221
+
222
+ RESTForge has **two different auth mechanisms — do not confuse them.** Pick the
223
+ right one; never describe one as the other, and never claim the extension does RBAC.
224
+
225
+ | Mechanism | RBAC? | How |
226
+ |---|---|---|
227
+ | **Plugin auth** — built into the frontend at generation time | **Yes (auth + RBAC)** | `vanilla-js-auth` or `vanilla-js-custom` plugin in `designer_init_project`; disable with `noAuth: true` (`--no-auth`) |
228
+ | **Auth extension** — bolt-on added to an existing project | **No RBAC** | backend `project_auth`; frontend `designer_auth_create` (embedded `rfx_auth`) |
229
+
230
+ Confirm which plugins provide auth with `designer_list_plugins` — do not hardcode
231
+ it. The rest of this section covers the **extension** (the no-RBAC bolt-on); for
232
+ plugin auth see Decision Points § Frontend plugin choice. Google Sign-In and
233
+ `@restforgejs/auth` are out of scope for the extension.
234
+
235
+ ### Backend auth — `project_auth`
236
+
237
+ Adds the auth backend to an existing RESTForge project (run the standard backend
238
+ pipeline first; the project and its endpoint must already exist, and the DB must
239
+ be active).
240
+
241
+ ```
242
+ project_auth (wraps: npx restforge project auth --create --project=<name>)
243
+ ```
244
+
245
+ Installs auth SDF (`rfx`), DB tables, middleware, router, six processors
246
+ (register/login/refresh/logout/me/reset-password), a random `JWT_SECRET`, and
247
+ `bcrypt`+`jsonwebtoken`. Idempotent. → references/auth.md § Backend
248
+
249
+ ### Frontend auth — `designer_auth_create` / `designer_auth_remove`
250
+
251
+ Adds (or removes) an **embedded** login / signup / forget-password overlay
252
+ (`rfx_auth`) on an existing frontend project, at route
253
+ `/api/<project>/rfx_auth`. This is independent of the `vanilla-js-auth` plugin.
254
+
255
+ ```
256
+ designer_auth_create (wraps: restforge-designer auth --create --project=<name>)
257
+ designer_auth_remove (wraps: restforge-designer auth --remove --project=<name> --force)
258
+ ```
259
+
260
+ `create` writes the auth pages + `js/rfx_auth.js` and injects a guard into existing
261
+ pages; `remove` deletes them. Idempotent. `restforge-designer` must be on PATH.
262
+ → references/auth.md § Frontend
263
+
264
+ Do not combine the two mechanisms on one app: if an app already has plugin auth
265
+ (`vanilla-js-auth` / `vanilla-js-custom`), do not also add embedded `rfx_auth`.
266
+
267
+ ---
268
+
207
269
  ## Grounding-First Rules
208
270
 
209
271
  Before reasoning about, proposing, or generating any **definition content** —
@@ -238,8 +300,10 @@ type, or wrong semantics. Two concrete failure modes this rule prevents:
238
300
  constraint, not RDF `fieldValidation`. Grounding surfaces this distinction
239
301
  before the agent commits to the wrong one.
240
302
 
241
- The reference files mirror the catalog for offline reasoning, but the live
242
- catalog tool is authoritative — when they disagree, trust the tool.
303
+ The reference files help you *understand* the catalog; they do **not** replace
304
+ the tool. Call the tool to ground, produce, and validate — do not hand-produce
305
+ output a tool would generate. The live tool is authoritative; when a reference and
306
+ the tool disagree, trust the tool.
243
307
 
244
308
  ---
245
309
 
@@ -321,12 +385,25 @@ branch still obeys the Grounding-First Rules above.
321
385
 
322
386
  ### Frontend plugin choice
323
387
 
324
- - **No authentication required** → `vanilla-js-basic`.
325
- - **JWT authentication required** → `vanilla-js-auth`.
326
- - **Custom branding / behavior** → `designer_scaffold_plugin` to create a new
327
- plugin from template.
388
+ - **No auth** → `vanilla-js-basic`.
389
+ - **Auth WITH RBAC, built into the app** → `vanilla-js-auth` or
390
+ `vanilla-js-custom` at `designer_init_project`. Use `noAuth: true` (`--no-auth`)
391
+ to get the plugin's UI without its auth.
392
+ - **Custom branding / new plugin** → `designer_scaffold_plugin`.
393
+ - **Bolt-on auth WITHOUT RBAC** → not a plugin; see Authentication below.
328
394
  → references/udf-catalog.md § Plugins
329
395
 
396
+ ### Authentication
397
+
398
+ - **Needs RBAC** → plugin auth (`vanilla-js-auth` / `vanilla-js-custom`) at
399
+ `designer_init_project`. The extension below does **not** do RBAC.
400
+ - **Backend auth on an existing project (no RBAC)** → `project_auth` (after the
401
+ project and its endpoint exist, with an active DB).
402
+ - **Frontend auth on an app built WITHOUT plugin auth (no RBAC)** →
403
+ `designer_auth_create` (embedded `rfx_auth`).
404
+ - **Remove embedded frontend auth** → `designer_auth_remove` — destructive,
405
+ confirm first (see Guardrails).
406
+
330
407
  ---
331
408
 
332
409
  ## Guardrails
@@ -376,6 +453,20 @@ widgets, or UDF content from memory. Call the matching catalog tool first (see
376
453
  Grounding-First Rules). Inventing an option that "should" exist is the most
377
454
  common way to produce confidently wrong output.
378
455
 
456
+ **7. Confirm before removing embedded auth.**
457
+ `designer_auth_remove` deletes the auth files (`login.html`, `signup.html`, the
458
+ forget-password overlay, `js/rfx_auth.js`) and strips the guard from existing
459
+ pages. Under MCP it runs with `--force` (no interactive prompt), so confirm the
460
+ project name and intent with the user **before** calling it.
461
+
462
+ **8. Execute through tools; never emulate them.** The bundled `references/` help
463
+ you *understand* options — they do not replace the tools. When a tool can produce
464
+ or validate an artifact (`codegen_dbschema_template`/`init`,
465
+ `codegen_generate_payload`, any `*_validate_*`), **call it**; do not hand-write its
466
+ output by reading a reference. Emulating the generator is slower, loses
467
+ determinism, and drifts from what the installed version emits. If the tool is not
468
+ available, stop (see Preflight) rather than improvising from the references.
469
+
379
470
  ---
380
471
 
381
472
  ## Prerequisites and Common Errors
@@ -0,0 +1,142 @@
1
+ # Reference: Auth Extension
2
+
3
+ > **Offline mirror.** This file mirrors the auth commands of the installed
4
+ > RESTForge platform and Designer (`restforge project auth`, `restforge-designer
5
+ > auth`). The live tools/CLI are authoritative — when this file and them disagree,
6
+ > trust the tools, then update this file.
7
+
8
+ **This file documents the auth EXTENSION — auth WITHOUT RBAC.** It is one of two
9
+ distinct auth mechanisms; do not confuse them:
10
+
11
+ | Mechanism | RBAC? | Where |
12
+ |---|---|---|
13
+ | **Plugin auth** — built into the frontend at generation | **Yes (auth + RBAC)** | `vanilla-js-auth` / `vanilla-js-custom` plugin, chosen at `designer_init_project`; toggle off with `noAuth: true` (`--no-auth`). See `udf-catalog.md § Plugins`. |
14
+ | **Auth extension** (this file) | **No RBAC** | `project_auth` (backend) + `designer_auth_create` (frontend `rfx_auth`) |
15
+
16
+ The extension is an optional add-on installed into a project that already exists.
17
+ Backend auth and frontend auth are **independent**: install either, both, or
18
+ neither. Both are JWT-based.
19
+
20
+ **Out of scope for the extension:** Google Sign-In, RBAC, and the
21
+ `@restforgejs/auth` package. The embedded frontend flow is independent of the
22
+ `vanilla-js-auth` plugin — if the user needs RBAC, use plugin auth, not this.
23
+
24
+ ---
25
+
26
+ ## Backend
27
+
28
+ MCP tool: `project_auth` — wraps `npx restforge project auth --create`.
29
+
30
+ ```
31
+ npx restforge project auth --create --project=<name> [options]
32
+ ```
33
+
34
+ | Flag | Required | Default | Notes |
35
+ |---|---|---|---|
36
+ | `--create` | yes | `false` | Required trigger; must be present |
37
+ | `--project <name>` | yes* | — | Target project name |
38
+ | `--name <name>` | yes* | — | Alias of `--project` |
39
+ | `--schema-path <dir>` | no | `./schema` | Output folder for auth SDF files |
40
+ | `--config <file>` | no | `config/db-connection.env` | DB config for the migrate step |
41
+ | `--force` | no | `false` | Overwrite existing files (backup still made) |
42
+
43
+ \* one of `--project` / `--name` is required.
44
+
45
+ MCP params: `cwd` (project folder, must contain `node_modules/@restforgejs/platform`),
46
+ `project`, `schemaPath?`, `config?`, `force?`.
47
+
48
+ **What it does (in order):**
49
+ 1. Generates auth SDF files (prefix `rfx`) to `--schema-path`.
50
+ 2. Creates auth DB tables via dbschema-kit (idempotent, `IF NOT EXISTS`).
51
+ 3. Writes auth middleware + router.
52
+ 4. Writes six processors: `register`, `login`, `refresh`, `logout`, `me`,
53
+ `reset-password`.
54
+ 5. Injects auth env vars (random `JWT_SECRET`) into the config file.
55
+ 6. Records `bcrypt` + `jsonwebtoken` as runtime dependencies in the project's
56
+ `package.json`.
57
+
58
+ **Prerequisites:** the project already exists (run `endpoint create` /
59
+ the standard backend pipeline first), `@restforgejs/platform` is installed in the
60
+ project, and the DB is active and reachable with the config credentials.
61
+
62
+ Idempotent (re-runnable). Non-destructive aside from `--force` overwrites, which
63
+ still create a backup.
64
+
65
+ ---
66
+
67
+ ## Frontend
68
+
69
+ Embedded login / signup / forget-password overlay (`rfx_auth`), mounted at route
70
+ `/api/<project>/rfx_auth`. Independent of the `vanilla-js-auth` plugin.
71
+
72
+ MCP tools: `designer_auth_create`, `designer_auth_remove` — wrap
73
+ `restforge-designer auth --create | --remove`.
74
+
75
+ ```
76
+ restforge-designer auth --create --project=<name> [options]
77
+ restforge-designer auth --remove --project=<name> [--frontend-path <path>] --force
78
+ ```
79
+
80
+ `--create` and `--remove` are mutually exclusive; exactly one is required.
81
+
82
+ | Flag | Applies to | Default | Notes |
83
+ |---|---|---|---|
84
+ | `--create` | create | — | Install the overlay |
85
+ | `--remove` | remove | — | Uninstall the overlay |
86
+ | `--project <name>` | both | — | App code, localStorage prefix, route `/api/<project>/rfx_auth` |
87
+ | `--frontend-path <path>` | both | `./frontend/apps` | Apps root; target app = `<frontend-path>/<project>` |
88
+ | `--api-base-url <url>` | create | from `app-config.json` | Override backend base URL |
89
+ | `--plugins-dir <dir>` | both | auto-detect | Plugins directory |
90
+ | `--overwrite` | create | `false` | Overwrite existing auth files (+ archive backup) |
91
+ | `--force` | remove | `false` | Skip the y/N removal prompt |
92
+
93
+ MCP params — `designer_auth_create`: `cwd`, `project`, `frontendPath?`,
94
+ `apiBaseUrl?`, `overwrite?`. `designer_auth_remove`: `cwd`, `project`,
95
+ `frontendPath?` (the MCP tool always passes `--force`).
96
+
97
+ **`--create` does (in order):**
98
+ 1. Renders `login.html`, `signup.html`, the forget-password overlay, and
99
+ `js/rfx_auth.js` from embedded templates (no Google Sign-In).
100
+ 2. Writes the artifacts to `<frontend-path>/<project>/`.
101
+ 3. Injects an auth guard `<script src="js/rfx_auth.js">` into all existing
102
+ `*.html` pages in the target dir (except `login.html` / `signup.html`).
103
+ 4. Writes the `embeddedAuth` marker to `payload/app-config.json` (non-destructive;
104
+ other keys untouched).
105
+
106
+ If no app pages exist yet, guard injection is skipped with a warning; the guard is
107
+ injected automatically when `designer_generate` creates pages later.
108
+
109
+ **`--remove` does (in order):**
110
+ 1. Detects whether auth is installed (files + `embeddedAuth` marker).
111
+ 2. Deletes `login.html`, `signup.html`, the forget-password overlay,
112
+ `js/rfx_auth.js`.
113
+ 3. Strips the auth guard from all `*.html` pages (other content untouched).
114
+ 4. Removes the `embeddedAuth` key from `payload/app-config.json` (other keys kept).
115
+
116
+ **Prerequisites:** the `restforge-designer` binary is installed and on PATH.
117
+
118
+ Both are idempotent. **`--remove` is destructive** — confirm project name and
119
+ intent with the user before running (MCP always passes `--force`).
120
+
121
+ ---
122
+
123
+ ## Two frontend auth approaches — do not combine
124
+
125
+ | Approach | RBAC? | When | How |
126
+ |---|---|---|---|
127
+ | Plugin auth (`vanilla-js-auth`, `vanilla-js-custom`) | **Yes (auth + RBAC)** | A new app that needs auth/RBAC | Choose the plugin in `designer_init_project`; auth is built in at generation. Disable with `noAuth: true` (`--no-auth`) |
128
+ | Embedded `rfx_auth` | **No RBAC** | An existing app generated WITHOUT plugin auth | `designer_auth_create` bolts auth on |
129
+
130
+ Do not add `rfx_auth` to an app already built with plugin auth — they are two
131
+ separate mechanisms. If the user needs RBAC, only plugin auth provides it.
132
+
133
+ ---
134
+
135
+ ## Common errors
136
+
137
+ | Symptom | Cause | Recovery |
138
+ |---|---|---|
139
+ | Backend: "package not installed" precondition | `@restforgejs/platform` missing in the project | Install the package, then re-run |
140
+ | Backend: project does not exist / DB not reachable | Auth runs against an existing project + live DB | Create the project + endpoints first; verify DB config |
141
+ | Frontend: "Designer not on PATH" precondition | `restforge-designer` binary missing | Install RESTForge Designer and ensure it is on PATH |
142
+ | Frontend: files already exist, not overwritten | Auth already installed | Use `--overwrite` (create) only if you intend to replace |
@@ -471,14 +471,21 @@ an event over the WebSocket channel.
471
471
 
472
472
  ## Plugins
473
473
 
474
- Two built-in plugins. Run `designer_list_plugins` to confirm available versions.
474
+ Built-in plugins. Run `designer_list_plugins` to confirm what the installed
475
+ version provides — do not hardcode this list.
475
476
 
476
477
  | Plugin | Auth | Notes |
477
478
  |---|---|---|
478
479
  | `vanilla-js-basic` | None | Standard CRUD app, no login flow |
479
- | `vanilla-js-auth` | JWT | Includes login page, token refresh, role-based visibility |
480
+ | `vanilla-js-auth` | Auth + RBAC | Login page, token refresh, role-based access |
481
+ | `vanilla-js-custom` | Auth + RBAC | Customisable markup/CSS/JS; auth + RBAC capable (confirm via `designer_list_plugins`) |
480
482
 
481
- `vanilla-js-auth` requires additional `appConfig` properties:
483
+ Plugin auth is built into the app at generation time. Disable it with
484
+ `noAuth: true` (`--no-auth`) on `designer_init_project` to get the plugin's UI
485
+ without auth. **Plugin auth (with RBAC) is distinct from the embedded `rfx_auth`
486
+ extension** (`designer_auth_create`, no RBAC) — see references/auth.md.
487
+
488
+ `vanilla-js-auth` accepts additional `appConfig` / init properties:
482
489
  - `authAppCode` — must match the backend auth module's app code
483
490
  - `idleTimeout` — auto-logout after inactivity (seconds)
484
491