@quixomatic/rpf 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +74 -2
- package/assets/react-portal-lockup-on-dark.svg +11 -0
- package/assets/react-portal-lockup.svg +11 -0
- package/dist/cli.mjs +12700 -0
- package/package.json +61 -5
- package/skills/react-portal/SKILL.md +160 -0
- package/skills/react-portal/references/cli.md +141 -0
- package/skills/react-portal/references/components.md +214 -0
- package/skills/react-portal/references/rules.md +115 -0
- package/skills/react-portal/references/troubleshooting.md +58 -0
- package/skills/react-portal/references/workspace.md +178 -0
- package/skills/react-portal-theme/SKILL.md +110 -0
package/package.json
CHANGED
|
@@ -1,6 +1,62 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@quixomatic/rpf",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "React Portal from the terminal: instance profiles, sign-in, new draft portals, local workspaces, live lookups, built-in Claude Code skills, health checks and the Forge MCP server for ServiceNow instances running React Portal.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"bin": {
|
|
11
|
+
"rpforge": "dist/cli.mjs",
|
|
12
|
+
"rpf": "dist/cli.mjs"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"skills",
|
|
17
|
+
"assets",
|
|
18
|
+
"LICENSE",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=24"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"servicenow",
|
|
26
|
+
"react-portal",
|
|
27
|
+
"forge",
|
|
28
|
+
"cli",
|
|
29
|
+
"mcp"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "bun run scripts/build.ts",
|
|
33
|
+
"dev": "bun run src/cli.ts",
|
|
34
|
+
"typecheck": "bunx tsc --noEmit",
|
|
35
|
+
"test": "bun run test/cli.ts && bun run test/init.ts && bun run test/skills.ts && bun run test/seed.ts",
|
|
36
|
+
"test:dist": "bun run build && bun run test/cli.ts --dist && bun run test/init.ts --dist && bun run test/skills.ts --dist && bun run test/seed.ts --dist",
|
|
37
|
+
"test:mcp": "bun run test/mcp.ts",
|
|
38
|
+
"test:workspace": "bun run test/workspace.ts",
|
|
39
|
+
"test:live": "bun run test/workspace.ts --live",
|
|
40
|
+
"check:pack": "bun run build && bun run scripts/check-pack.ts",
|
|
41
|
+
"test:init": "bun run test/init.ts",
|
|
42
|
+
"test:skills": "bun run test/skills.ts",
|
|
43
|
+
"test:seed": "bun run test/seed.ts",
|
|
44
|
+
"release:cli": "bun run scripts/release-cli.ts"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@clack/prompts": "1.9.0",
|
|
48
|
+
"@modelcontextprotocol/sdk": "1.32.2",
|
|
49
|
+
"@napi-rs/keyring": "2.1.2",
|
|
50
|
+
"ajv": "8.17.1",
|
|
51
|
+
"commander": "15.1.0",
|
|
52
|
+
"culori": "4.0.2",
|
|
53
|
+
"picocolors": "1.1.1",
|
|
54
|
+
"prettier": "3.6.1",
|
|
55
|
+
"undici": "8.13.1"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@types/bun": "latest",
|
|
59
|
+
"@types/node": "24.x",
|
|
60
|
+
"typescript": "5.5.4"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: react-portal
|
|
3
|
+
description: Build and change React Portal portals on a ServiceNow instance with the rpforge CLI. Covers new draft portals (rpforge init), local workspaces (pull, status, diff, check, push), components (widgets, primitives, blocks, layouts, utilities) written as main.tsx, server.js and options.schema.json, and portal.mjs pages, menus, side panels and placements. Use it when the user works in a React Portal workspace (forge.workspace.json, portal.mjs, components/@ns/key folders), mentions rpforge, React Portal or Forge, or asks for a ServiceNow portal, page or widget built with React.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# React Portal with rpforge
|
|
7
|
+
|
|
8
|
+
React Portal is a ServiceNow application that serves React 19 portals. A portal is made of records on the instance:
|
|
9
|
+
pages, page variants, side panels, menus, placements, a theme, and **components**, which are React code compiled on
|
|
10
|
+
the instance. `rpforge` is the CLI that brings a portal into local files (a **workspace**), lets you edit it with
|
|
11
|
+
ordinary tools, and pushes the changes back through the instance's Forge API, as the signed-in user, with their roles.
|
|
12
|
+
|
|
13
|
+
Read the reference pages when the task needs them:
|
|
14
|
+
|
|
15
|
+
- [references/cli.md](references/cli.md): every command, the flags agents use, JSON output, exit codes.
|
|
16
|
+
- [references/workspace.md](references/workspace.md): the folder layout and the `portal.mjs` format.
|
|
17
|
+
- [references/components.md](references/components.md): component kinds and files, `@portal/runtime`, the host kit.
|
|
18
|
+
- [references/rules.md](references/rules.md): the hard rules, each with the failure it prevents. **Read before writing code.**
|
|
19
|
+
- [references/troubleshooting.md](references/troubleshooting.md): sign-in errors, the kill switch, stale plans, conflicts.
|
|
20
|
+
- Themes: the `react-portal-theme` skill.
|
|
21
|
+
|
|
22
|
+
## Ground rules
|
|
23
|
+
|
|
24
|
+
- **Drafts only. Never publish.** rpforge has no publish command. New portals are inactive drafts; a person with the
|
|
25
|
+
publish capability publishes in Studio (Portals activity). Don't try to set `active: true` on a portal.
|
|
26
|
+
- **Never delete.** Pushes never delete records. To remove a page, placement, panel, variant or menu item, keep it in
|
|
27
|
+
`portal.mjs` with `active: false`. Extra source files are deleted on the instance only when listed in
|
|
28
|
+
`--remove-files`.
|
|
29
|
+
- **Every write is two steps.** Run the dry run, show the user the plan (what's created, updated, deactivated, the
|
|
30
|
+
target application and update set), and only then write that exact plan with its hash. Don't add `--yes` on the
|
|
31
|
+
user's behalf for anything beyond what they asked for.
|
|
32
|
+
- **`--force` overwrites other people's instance changes.** Use it only when the user asks, and only with
|
|
33
|
+
`--yes --confirm <slug>`.
|
|
34
|
+
- **Don't route around Forge.** If the kill switch is off (`forge_mcp_disabled`, exit code 4), stop and tell the user;
|
|
35
|
+
an admin turns it back on. Don't fall back to other APIs.
|
|
36
|
+
- **Commit the files and `forge.workspace.json` together.** The manifest holds the base state the files were written
|
|
37
|
+
against.
|
|
38
|
+
|
|
39
|
+
## 1. Set up and check
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
rpforge auth add dev --instance dev12345 --kind oauth-code
|
|
43
|
+
rpforge auth login dev
|
|
44
|
+
rpforge doctor
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`rpforge doctor` (add `--json` to parse it) checks the sign-in, the kill switch, the user's Studio capabilities
|
|
48
|
+
(`author` writes component code, `design` writes portals, pages and themes), and compatibility:
|
|
49
|
+
|
|
50
|
+
- **Forge API level.** The instance reports a level and rpforge speaks a range. Below the range: React Portal on the
|
|
51
|
+
instance needs an update. Above it: update rpforge (`npm i -g @quixomatic/rpf`).
|
|
52
|
+
- **Global Helpers** (a small global-scope companion app): 1.3.0+ to write into an application and update set, 1.6.0+
|
|
53
|
+
for images, **1.7.0+ to create a new update set** (`init --new-update-set`).
|
|
54
|
+
|
|
55
|
+
Profiles: `rpforge auth list`, `rpforge auth use dev`, `rpforge auth status`. Inside a workspace, rpforge picks the
|
|
56
|
+
profile whose instance the workspace tracks; `--profile` overrides.
|
|
57
|
+
|
|
58
|
+
## 2. A new portal: `rpforge init`
|
|
59
|
+
|
|
60
|
+
`init` asks for the owning application, the update set, name and slug, the starting point (a template, a copy of a
|
|
61
|
+
portal, or empty), layout, theme, brand, navigation and audience, then the local folder. It writes nothing until the
|
|
62
|
+
plan is confirmed. As an agent, run it in two steps:
|
|
63
|
+
|
|
64
|
+
```sh
|
|
65
|
+
rpforge init --no-interactive --app x_acme_hr --new-update-set --name "HR Portal" --brand-color "#2563eb"
|
|
66
|
+
rpforge init --no-interactive --app x_acme_hr --new-update-set --name "HR Portal" --brand-color "#2563eb" --yes --request-id hr-portal-1
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
- The first run is the dry run: it prints the instance's plan and how to create it. Show the plan to the user.
|
|
70
|
+
- The second run (same answers plus `--yes`) creates the draft and pulls it into `./hr-portal` (or `apps/hr-portal`
|
|
71
|
+
when the folder has `apps/`; `--out` picks the folder). Use a fixed `--request-id`: a retry with the same id replays
|
|
72
|
+
instead of creating a second portal.
|
|
73
|
+
- A missing answer is exit code 2 naming the flag. `rpforge init --answers-schema` prints the answers file format;
|
|
74
|
+
`rpforge init --answers init.json --no-interactive` takes them all from a file.
|
|
75
|
+
- The owning application can't be React Portal itself or Global: React Portal's own portals belong to its demo seed
|
|
76
|
+
and can't be workspaces. Pick (or ask for) the customer's scoped application.
|
|
77
|
+
|
|
78
|
+
## 3. An existing portal: `rpforge pull`
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
rpforge portals
|
|
82
|
+
rpforge pull hr-portal --update-set "HR Portal (React Portal)"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
The first pull needs the in-progress update set (of the portal's application) that pushes will write into. Pulling
|
|
86
|
+
again inside the workspace re-syncs it three ways: instance changes come in, local changes stay, conflicts are left
|
|
87
|
+
for `rpforge resolve`. A pull never writes to the instance.
|
|
88
|
+
|
|
89
|
+
## 4. The loop
|
|
90
|
+
|
|
91
|
+
1. **Look before you build.** Reuse what exists (see "Look it up live" below).
|
|
92
|
+
2. **Edit files.** `portal.mjs` for structure, `components/@<ns>/<key>/` for code, `themes/<key>/` for the theme. New
|
|
93
|
+
component: `rpforge new component acme/order-card --kind widget` (kinds: widget, primitive, block, layout,
|
|
94
|
+
utility).
|
|
95
|
+
3. **`rpforge status`**: local changes, instance changes made meanwhile (who and when), conflicts, untracked files.
|
|
96
|
+
`rpforge diff page:home` shows one entry; `rpforge diff --against instance` compares with the instance now.
|
|
97
|
+
4. **`rpforge check`**: Prettier, a lint for the hard rules, the instance compiling every changed component (nothing
|
|
98
|
+
saved), and the push dry run. Fix everything it reports. `rpforge check --tsc` adds a type check.
|
|
99
|
+
5. **Push in two steps:**
|
|
100
|
+
|
|
101
|
+
```sh
|
|
102
|
+
rpforge push --no-interactive
|
|
103
|
+
rpforge push --plan-hash 3f9c2a7e
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
The first command prints the plan and its `planHash`. After the user agrees, the second writes exactly that plan.
|
|
107
|
+
If anything changed in between (files or instance), it's refused: run the dry run again.
|
|
108
|
+
6. Commit the files and `forge.workspace.json`.
|
|
109
|
+
|
|
110
|
+
Conflicts: `rpforge resolve take-instance page:home`, `rpforge resolve take-local page:home` or
|
|
111
|
+
`rpforge resolve merge page:home`. Renames that keep the record (and its sys_id):
|
|
112
|
+
`rpforge rename page:pipeline page:deals`. Never rename by editing keys by hand: that reads as a new record plus a
|
|
113
|
+
removed one.
|
|
114
|
+
|
|
115
|
+
Pushes write into the portal's application and the workspace's update set (each request switches, verifies, writes and
|
|
116
|
+
restores the user's own picker). Compiles and one reprocess run in the same request, so the update set stays
|
|
117
|
+
self-sufficient.
|
|
118
|
+
|
|
119
|
+
## 5. Look it up live
|
|
120
|
+
|
|
121
|
+
The instance is the source of truth for what exists: its catalog and docs change with each React Portal upgrade, so
|
|
122
|
+
look them up instead of guessing.
|
|
123
|
+
|
|
124
|
+
```sh
|
|
125
|
+
rpforge components --kind primitive
|
|
126
|
+
rpforge components record form
|
|
127
|
+
rpforge components get app/record-form
|
|
128
|
+
rpforge docs server script
|
|
129
|
+
rpforge docs read authoring/server-script
|
|
130
|
+
rpforge api useServer
|
|
131
|
+
rpforge api components:card
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
- `components` searches the catalog (default 100 results; `--limit`, `--kind`). `components get` shows a component's
|
|
135
|
+
import specifier, options schema, defaults, regions and exports.
|
|
136
|
+
- `docs` searches the React Portal guide and API reference on the instance; `docs read <path>` prints a page
|
|
137
|
+
(`--heading` for one section). Good starting pages: `primitives/overview`, `concepts/component-kinds`,
|
|
138
|
+
`authoring/client-script`, `authoring/server-script`, `authoring/options`, `authoring/styling`,
|
|
139
|
+
`runtime-api/overview`, `runtime-api/host-kit`.
|
|
140
|
+
- `api` gives the exact signature of a hook, kit module or record component. Check it before importing anything.
|
|
141
|
+
|
|
142
|
+
Every lookup is read-only and takes `--json`.
|
|
143
|
+
|
|
144
|
+
## 6. The hard rules (summary)
|
|
145
|
+
|
|
146
|
+
Details and reasons in [references/rules.md](references/rules.md).
|
|
147
|
+
|
|
148
|
+
- Server code (`server.js`): **no array spread** (`[...a]`, `f(...args)`, `push(...x)`); use `concat` or loops, and
|
|
149
|
+
test arrays with `arr && arr.length`. Follow the owning application's JavaScript mode (ES5 apps: `var`, no arrows).
|
|
150
|
+
- Never name a local, parameter or prop `exports`, `module` or `require`.
|
|
151
|
+
- Inline styles and SVG use `var(--card)`, `var(--primary)`, `var(--chart-1)`; there are **no `--color-*`
|
|
152
|
+
variables**.
|
|
153
|
+
- Responsive display variants: write `sm:block!` / `max-sm:flex!` (important) when a widget toggles `hidden` / `block`
|
|
154
|
+
/ `flex` by breakpoint. `rpforge check` flags them.
|
|
155
|
+
- Prettier style: semicolons, single quotes, 4 spaces, 120 columns, es5 trailing commas, LF.
|
|
156
|
+
- Use the host's libraries (React 19, TanStack, shadcn on Base UI, Tailwind v4, TipTap, CodeMirror, Recharts, motion,
|
|
157
|
+
dnd-kit) through their registry modules; npm packages can't be imported.
|
|
158
|
+
- Server scripts start with an empty `data` on every call; the client's data is never sent back. Put what the script
|
|
159
|
+
needs in `input`.
|
|
160
|
+
- Never publish, never delete; two-step writes; `--force` only when asked.
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# rpforge command reference
|
|
2
|
+
|
|
3
|
+
`rpforge` (alias `rpf`) needs Node 24 or newer. `rpforge --help` and `rpforge <command> --help` list every flag; this
|
|
4
|
+
page covers what an agent needs.
|
|
5
|
+
|
|
6
|
+
## Global flags
|
|
7
|
+
|
|
8
|
+
They work before or after the command.
|
|
9
|
+
|
|
10
|
+
| Flag | Meaning |
|
|
11
|
+
|---|---|
|
|
12
|
+
| `-p, --profile <name>` | The profile to use (else `RPFORGE_PROFILE`, the workspace's instance, the default) |
|
|
13
|
+
| `--dir <folder>` | The workspace folder (default: the current folder and its parents); for a new pull, where it goes |
|
|
14
|
+
| `--json` | One JSON document on stdout, progress on stderr |
|
|
15
|
+
| `--no-interactive` | Never prompt: a missing answer is exit code 2 naming the flag that supplies it |
|
|
16
|
+
| `-y, --yes` | Accept plans and confirmations |
|
|
17
|
+
| `--dry-run` | Every write becomes a dry run |
|
|
18
|
+
| `-q, --quiet` | No progress output |
|
|
19
|
+
| `--no-color`, `--debug` | Plain output; stack traces on errors |
|
|
20
|
+
|
|
21
|
+
Without a terminal (an agent's shell, CI) rpforge never prompts, the same as `--no-interactive`.
|
|
22
|
+
|
|
23
|
+
## JSON and exit codes
|
|
24
|
+
|
|
25
|
+
With `--json` every command prints `{ "ok": true, "command": "...", ... }`. Workspace commands include `profile` and
|
|
26
|
+
`instance` and the same result object the Forge MCP's `workspace_*` tools return. Errors are
|
|
27
|
+
`{ "ok": false, "command": "...", "error": { "code", "message", "details" } }`.
|
|
28
|
+
|
|
29
|
+
| Exit code | Meaning |
|
|
30
|
+
|---|---|
|
|
31
|
+
| 0 | ok |
|
|
32
|
+
| 1 | refused, failed, a check that isn't ok, or open conflicts |
|
|
33
|
+
| 2 | usage or missing input |
|
|
34
|
+
| 3 | sign-in (401, login required, the credential store) |
|
|
35
|
+
| 4 | Forge is switched off on the instance (the kill switch), or the instance is incompatible |
|
|
36
|
+
| 5 | network |
|
|
37
|
+
|
|
38
|
+
## Profiles and health
|
|
39
|
+
|
|
40
|
+
| Command | What it does |
|
|
41
|
+
|---|---|
|
|
42
|
+
| `rpforge auth add dev --instance dev12345 --kind oauth-code` | Adds a profile. Kinds: `basic`, `oauth-password`, `oauth-client`, `oauth-code`, `bearer`, `apikey`, `mtls`, `session`. Secrets come from stdin, an environment variable or a hidden prompt, never a plain flag |
|
|
43
|
+
| `rpforge auth login dev` | Browser sign-in (oauth-code), or fetches a token now (other OAuth kinds) |
|
|
44
|
+
| `rpforge auth list` | Profiles and token state, never secrets |
|
|
45
|
+
| `rpforge auth use dev` | Sets the default profile |
|
|
46
|
+
| `rpforge auth status` | Which profile and why, who Forge runs as |
|
|
47
|
+
| `rpforge auth logout dev` | Revokes and forgets cached OAuth tokens |
|
|
48
|
+
| `rpforge doctor` | Local and instance health: sign-in, kill switch, capabilities, Forge API level, Global Helpers version, Prettier, installed skills. `--quick` skips the version checks |
|
|
49
|
+
|
|
50
|
+
Without a profile store (CI), the environment is a complete configuration: `RP_INSTANCE`, `FORGE_AUTH`, `RP_USER`,
|
|
51
|
+
`RP_PASSWORD`, `RP_TOKEN` and so on.
|
|
52
|
+
|
|
53
|
+
## New portals
|
|
54
|
+
|
|
55
|
+
`rpforge init` is a wizard; every question has a flag (`rpforge init --help`).
|
|
56
|
+
|
|
57
|
+
| Command | What it does |
|
|
58
|
+
|---|---|
|
|
59
|
+
| `rpforge init --no-interactive --app x_acme_hr --update-set "HR Portal (React Portal)" --name "HR Portal"` | The dry run: the instance's plan. Nothing is written |
|
|
60
|
+
| `rpforge init --no-interactive --app x_acme_hr --update-set "HR Portal (React Portal)" --name "HR Portal" --yes --request-id hr-1` | Creates the draft, pulls it into a workspace. The same `--request-id` on a retry replays instead of duplicating |
|
|
61
|
+
| `rpforge init --no-interactive --app x_acme_hr --new-update-set --name "HR Portal" --dry-run` | Plans a new update set too (needs Global Helpers 1.7.0+) |
|
|
62
|
+
| `rpforge init --answers-schema` | The JSON schema of an answers file |
|
|
63
|
+
| `rpforge init --answers init.json --no-interactive --yes` | Every answer from a file |
|
|
64
|
+
| `rpforge init --save-answers init.json --no-interactive --app x_acme_hr --name "HR Portal"` | Writes the answers (no secrets) for reuse on another instance |
|
|
65
|
+
|
|
66
|
+
Useful answer flags: `--from template|portal|empty`, `--source <portal>`, `--pages all|none|<routes>`,
|
|
67
|
+
`--layout <uid>`, `--theme <key>`, `--theme-copy`, `--brand-color <color>`, `--brand-icon <lucide name>`,
|
|
68
|
+
`--footer <text>`, `--roles <list>`, `--out <folder>`, `--no-pull`, `--no-git`, `--no-skills`.
|
|
69
|
+
|
|
70
|
+
## App packs onto another instance
|
|
71
|
+
|
|
72
|
+
An app pack is a workspace folder (`portal.mjs`, `components/`, `themes/`, `assets/`) committed with its app.
|
|
73
|
+
The `seed` command puts it onto an instance that doesn't have the portal yet.
|
|
74
|
+
|
|
75
|
+
| Command | What it does |
|
|
76
|
+
|---|---|
|
|
77
|
+
| `rpforge seed ./hr-portal --no-interactive` | Preflight and the plan: the app exists, the update set, React Portal's version, every component the pack uses has a build, the pack's own components and themes are new, the slug is free; then the empty draft and the push, with one plan hash. Writes nothing |
|
|
78
|
+
| `rpforge seed ./hr-portal --no-interactive --new-update-set` | Plans a new update set ("<Portal name> (React Portal)") when the pack's set isn't on the target |
|
|
79
|
+
| `rpforge seed ./hr-portal --no-interactive --new-update-set --yes --plan-hash 79e144f4186f78d0` | Creates the update set and the empty draft, tracks the instance with an empty base and force-pushes the pack (compiles, one reprocess), all in that set |
|
|
80
|
+
| `rpforge seed ./hr-portal --no-interactive --app x_acme_test --slug hr-test --name "HR test" --update-set "HR test"` | Re-targets the pack (`portal.mjs` follows: slug, name, app, update set, its own `/site/<slug>` links) |
|
|
81
|
+
| `rpforge seed ./hr-portal --no-interactive --out ./hr-portal-prod` | Seeds a copy, for a pack that already tracks another instance |
|
|
82
|
+
| `rpforge seed ./hr-portal --no-interactive --yes` | On a pack that tracks the instance: finishes a seed whose push stopped, or reports nothing to push |
|
|
83
|
+
|
|
84
|
+
Seeds never publish and never delete. Records the empty draft made that the pack doesn't list stay on the instance
|
|
85
|
+
(`rpforge status` shows them as instance changes).
|
|
86
|
+
|
|
87
|
+
## Workspaces
|
|
88
|
+
|
|
89
|
+
| Command | What it does |
|
|
90
|
+
|---|---|
|
|
91
|
+
| `rpforge pull hr-portal --update-set "HR Portal (React Portal)"` | A fresh pull into `<folder>/<slug>` (`--out` for the exact folder). Inside a workspace, `rpforge pull` re-syncs it three ways. Read-only on the instance |
|
|
92
|
+
| `rpforge pull hr-portal --out ./hr --mode adopt --update-set "HR Portal (React Portal)"` | Adopts a folder that already has files (nothing overwritten; the instance becomes the base) |
|
|
93
|
+
| `rpforge status` | Local changes, instance changes (who and when), conflicts, renames, untracked files. Exit 1 with open conflicts |
|
|
94
|
+
| `rpforge diff` | Unified diffs for files, field diffs for `portal.mjs` records |
|
|
95
|
+
| `rpforge diff page:home --against instance` | One entry against the instance now (`base`, `instance`, `local-instance`) |
|
|
96
|
+
| `rpforge resolve take-instance page:home` | The instance's version wins |
|
|
97
|
+
| `rpforge resolve take-local page:home` | Yours wins; the next push writes it over the instance |
|
|
98
|
+
| `rpforge resolve merge components/@acme/order-card/main.tsx` | Files through `git merge-file`, records field by field |
|
|
99
|
+
| `rpforge check` | Prettier, the lint, the instance compile of changed components, the push dry run. Writes nothing |
|
|
100
|
+
| `rpforge check --tsc` | Adds `tsc --noEmit` over the components with the host's types (informational) |
|
|
101
|
+
| `rpforge check --update-set` | Adds update-set coverage (needs read access to update sets, normally admin) |
|
|
102
|
+
| `rpforge push --no-interactive` | The dry run: the plan and its `planHash` |
|
|
103
|
+
| `rpforge push --plan-hash 3f9c2a7e` | Writes exactly that plan; refused if anything changed since |
|
|
104
|
+
| `rpforge push --yes` | Dry run, then push it if it succeeds (only when the user asked for a direct push) |
|
|
105
|
+
| `rpforge push --force --yes --confirm hr-portal` | Makes the instance match the files, overwriting instance changes (listed in the dry run, saved under `.forge/overwritten/`). Only when the user asks |
|
|
106
|
+
| `rpforge push --remove-files components/@acme/order-card/old-row.tsx` | Also deletes those source files on the instance |
|
|
107
|
+
| `rpforge push --reprocess` | Finishes an interrupted push (owed compiles and the reprocess) |
|
|
108
|
+
| `rpforge rename page:pipeline page:deals` | Renames a record so the push updates it (same sys_id) |
|
|
109
|
+
| `rpforge new component acme/order-card --kind widget` | Scaffolds `components/@acme/order-card/` in the house style |
|
|
110
|
+
|
|
111
|
+
Keys, as `status` lists them: `page:<route>`, `variant:<route>#<key>`, `panel:<key>`, `menu:<key>`,
|
|
112
|
+
`item:<menu>/<label>`, `placement:<owner>/<key>`, `component:<ns>/<key>`, `theme:<key>`, or a file path.
|
|
113
|
+
|
|
114
|
+
## Lookups (read-only)
|
|
115
|
+
|
|
116
|
+
| Command | What it does |
|
|
117
|
+
|---|---|
|
|
118
|
+
| `rpforge portals` | Portals: slug, name, draft or live, owning app |
|
|
119
|
+
| `rpforge components order` | Search the component catalog (name, unique id, description) |
|
|
120
|
+
| `rpforge components --kind primitive --limit 300` | Every primitive (`widget`, `primitive`, `block`, `layout`, `utility`) |
|
|
121
|
+
| `rpforge components get app/record-list` | Import specifier, options schema, defaults, regions, exports |
|
|
122
|
+
| `rpforge docs page variants` | Search the guide and API reference: path, title, snippet |
|
|
123
|
+
| `rpforge docs read concepts/page-variants` | Print a page |
|
|
124
|
+
| `rpforge docs read authoring/styling --heading "Cascade layers"` | Print one section |
|
|
125
|
+
| `rpforge api useTableQuery` | Exact API reference for a hook or function |
|
|
126
|
+
| `rpforge api components:dialog` | A host-kit module and its exports |
|
|
127
|
+
| `rpforge api components:app/record-form` | A record component's props |
|
|
128
|
+
| `rpforge themes` | Themes and presets, which portals use them |
|
|
129
|
+
| `rpforge themes get ocean-breeze` | A theme's `tokens.json` and `theme.css` |
|
|
130
|
+
| `rpforge themes generate --color "#2563eb"` | Contrast-checked light and dark tokens from a brand color, made locally |
|
|
131
|
+
|
|
132
|
+
## Skills and the MCP server
|
|
133
|
+
|
|
134
|
+
| Command | What it does |
|
|
135
|
+
|---|---|
|
|
136
|
+
| `rpforge skills install` | Copies these skills into the project's `.claude/skills/` |
|
|
137
|
+
| `rpforge skills install --global` | Into `~/.claude/skills/` |
|
|
138
|
+
| `rpforge skills update` | Brings installed skills up to this rpforge; files you edited are reported and left alone |
|
|
139
|
+
| `rpforge skills update --force` | Overwrites edited files, saving yours as `<file>.orig` |
|
|
140
|
+
| `rpforge skills list` | What ships, and what's installed where |
|
|
141
|
+
| `rpforge mcp --profile dev` | The Forge MCP server on stdio (`claude mcp add forge -- rpforge mcp --profile dev`) |
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# Components
|
|
2
|
+
|
|
3
|
+
Every piece of portal code is a component record, compiled on the instance. In a workspace each one is a folder,
|
|
4
|
+
`components/@<ns>/<key>/`. Scaffold new ones with `rpforge new component acme/order-card --kind widget`;
|
|
5
|
+
`rpforge check` compiles them on the instance without saving; `rpforge push` creates them.
|
|
6
|
+
|
|
7
|
+
## Kinds
|
|
8
|
+
|
|
9
|
+
| Kind | For | Placed on pages? | Server script? | Imported as |
|
|
10
|
+
|---|---|---|---|---|
|
|
11
|
+
| `widget` | Content an admin drops on a page | yes | yes (`serverMode`) | `components:<ns>/<key>` (renders as an embedded instance) |
|
|
12
|
+
| `block` | Structure with drop zones (columns, grids, sections) | yes, and nests | no | `components:<ns>/<key>` |
|
|
13
|
+
| `layout` | The frame around pages: renders regions | chosen on the portal or page | optional | not importable |
|
|
14
|
+
| `primitive` | A building block other components compose (a field, a list, a dialog) | never | no | `components:<ns>/<key>` |
|
|
15
|
+
| `utility` | Code without UI (hooks, fetchers, formatting) | never | no | `utilities:<ns>/<key>` |
|
|
16
|
+
|
|
17
|
+
Choosing: something an admin places is a widget; page structure with zones is a block; anything two widgets would
|
|
18
|
+
share is a primitive (UI) or a utility (logic). Keep logic out of single widgets: export hooks and helpers from a
|
|
19
|
+
utility or primitive so other components can import them.
|
|
20
|
+
|
|
21
|
+
Namespace and key: lowercase letters, digits and dashes, starting with a letter. Use the customer's own namespace
|
|
22
|
+
(`acme`), never `app` (React Portal's).
|
|
23
|
+
|
|
24
|
+
## Files
|
|
25
|
+
|
|
26
|
+
| File | Record field | Notes |
|
|
27
|
+
|---|---|---|
|
|
28
|
+
| `component.json` | name, kind, description, tailwind, serverMode, placeable, active, regions, defaults | `defaults` is the default options object. `serverMode`: `on-load` (runs before first render and on every call), `on-demand` (only when the client calls), absent = none |
|
|
29
|
+
| `main.tsx` | client script | Required. **Default export = the component.** Named exports are what importers get |
|
|
30
|
+
| `server.js` | server script | Widgets and layouts |
|
|
31
|
+
| `options.schema.json` | options schema | JSON Schema; drives the page designer's form and embed filtering |
|
|
32
|
+
| `styles.css` | CSS | Unlayered, appended after Tailwind's output |
|
|
33
|
+
| anything else | extra source files | `.ts/.tsx/.js/.json` are bundled, `.css` appended in import order, `*.server.js` never reaches the client |
|
|
34
|
+
|
|
35
|
+
Reserved names that can't be extra files: `main.tsx`, `styles.css`, `server.js`, `options.schema.json`,
|
|
36
|
+
`options.defaults.json`, `regions.json`, `theme.css`, `tokens.json`. Limits: 1 MiB per file, 200 files per component.
|
|
37
|
+
|
|
38
|
+
## `main.tsx`
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
import { useServer } from '@portal/runtime';
|
|
42
|
+
import { Button } from 'components:button';
|
|
43
|
+
import { Card, CardContent, CardHeader, CardTitle } from 'components:card';
|
|
44
|
+
|
|
45
|
+
type Options = { title?: string; limit?: number };
|
|
46
|
+
type Case = { sysId: string; number: string; shortDescription: string };
|
|
47
|
+
|
|
48
|
+
export default function MyCases({ options = {} }: { options?: Options }) {
|
|
49
|
+
const { data, pending, server } = useServer();
|
|
50
|
+
const cases = ((data && data.cases) || []) as Case[];
|
|
51
|
+
return (
|
|
52
|
+
<Card>
|
|
53
|
+
<CardHeader>
|
|
54
|
+
<CardTitle>{options.title || 'My cases'}</CardTitle>
|
|
55
|
+
</CardHeader>
|
|
56
|
+
<CardContent className="flex flex-col gap-2">
|
|
57
|
+
{cases.map((c) => (
|
|
58
|
+
<div key={c.sysId} className="flex items-center justify-between gap-3 text-sm">
|
|
59
|
+
<span className="truncate">
|
|
60
|
+
{c.number} {c.shortDescription}
|
|
61
|
+
</span>
|
|
62
|
+
<Button
|
|
63
|
+
size="sm"
|
|
64
|
+
variant="outline"
|
|
65
|
+
disabled={pending}
|
|
66
|
+
onClick={() => server.update({ action: 'close', sysId: c.sysId })}
|
|
67
|
+
>
|
|
68
|
+
Close
|
|
69
|
+
</Button>
|
|
70
|
+
</div>
|
|
71
|
+
))}
|
|
72
|
+
{!cases.length && <p className="text-sm text-muted-foreground">Nothing open.</p>}
|
|
73
|
+
</CardContent>
|
|
74
|
+
</Card>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Props by kind: widgets get `{ instanceId, options, region }`; layouts `{ regions, options }` and render
|
|
80
|
+
`<Region name="main" />`; blocks call `useBlock()` (`{ options, regions, rootProps }`, spread `rootProps` on the root);
|
|
81
|
+
primitives and utilities get whatever the importer passes and run inside the importing widget.
|
|
82
|
+
|
|
83
|
+
What you can import:
|
|
84
|
+
|
|
85
|
+
| Specifier | What |
|
|
86
|
+
|---|---|
|
|
87
|
+
| `react`, `react-dom`, `react/jsx-runtime` | The host's React 19 (`React` is injected; no import needed for JSX) |
|
|
88
|
+
| `@portal/runtime` | The runtime API (below) |
|
|
89
|
+
| `components:<name>`, `utilities:<name>` | The host kit: shadcn on Base UI, icons, data libraries |
|
|
90
|
+
| `components:app/<key>`, `utilities:app/<key>` | React Portal's record primitives and utilities |
|
|
91
|
+
| `components:<ns>/<key>`, `utilities:<ns>/<key>` | Other components on the instance |
|
|
92
|
+
| `./parts/row` | Extra files of this component |
|
|
93
|
+
|
|
94
|
+
npm packages can't be imported. Classes built at runtime (`'bg-' + color`) are invisible to the Tailwind compiler:
|
|
95
|
+
write full class names.
|
|
96
|
+
|
|
97
|
+
## `@portal/runtime` essentials
|
|
98
|
+
|
|
99
|
+
Check exact signatures with `rpforge api <name>`.
|
|
100
|
+
|
|
101
|
+
| Export | Use |
|
|
102
|
+
|---|---|
|
|
103
|
+
| `useServer()` (alias `useComponent()`) | `{ data, pending, error, options, server }`; `server.get(input)` (returns data, doesn't replace it), `server.update(input)` (replaces `data`), `server.refresh()`, `server.setInput(k, v)`, `server.pinInputs(obj)` |
|
|
104
|
+
| `usePortal()`, `usePortalLocation()` | The portal, page, path and URL params |
|
|
105
|
+
| `Link`, `useNavigate()` | Navigation inside the portal (`<Link to="orders">`) |
|
|
106
|
+
| `useRecord`, `useTableQuery` | Table data through the page's shared TanStack Query cache |
|
|
107
|
+
| `useRecordWatch` | Live updates when records change |
|
|
108
|
+
| `useUser`, `useProperty`, `useMessage`, `toast`, `format` | The user, system properties, translated messages, toasts, formatting |
|
|
109
|
+
| `useTheme` | Light / dark / system (`theme`, `setTheme`, `resolvedTheme`) |
|
|
110
|
+
| `useSidePanel` | Open and close side panels |
|
|
111
|
+
| `Embed`, `useGetWidget` | Embed another widget |
|
|
112
|
+
| `Region`, `useLayout`, `useBlock` | Layouts and blocks |
|
|
113
|
+
| `usePortalContainer` | The overlay element: target it if you create your own React portal (never `document.body`) |
|
|
114
|
+
|
|
115
|
+
## `server.js`
|
|
116
|
+
|
|
117
|
+
An IIFE that fills `data`, like a Service Portal server script:
|
|
118
|
+
|
|
119
|
+
```js
|
|
120
|
+
(function () {
|
|
121
|
+
var limit = Math.min(parseInt(options.limit, 10) || 10, 50);
|
|
122
|
+
if (input && input.action === 'close' && input.sysId) {
|
|
123
|
+
var rec = new GlideRecordSecure('x_acme_hr_case');
|
|
124
|
+
if (rec.get(input.sysId) && rec.canWrite()) {
|
|
125
|
+
rec.setValue('state', 'closed');
|
|
126
|
+
rec.update();
|
|
127
|
+
$sp.addSuccessMessage('Case closed');
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
var cases = [];
|
|
131
|
+
var gr = new GlideRecordSecure('x_acme_hr_case');
|
|
132
|
+
gr.addQuery('opened_by', gs.getUserID());
|
|
133
|
+
gr.addActiveQuery();
|
|
134
|
+
gr.orderByDesc('sys_created_on');
|
|
135
|
+
gr.setLimit(limit);
|
|
136
|
+
gr.query();
|
|
137
|
+
while (gr.next()) {
|
|
138
|
+
cases.push({
|
|
139
|
+
sysId: gr.getUniqueValue(),
|
|
140
|
+
number: gr.getValue('number'),
|
|
141
|
+
shortDescription: gr.getValue('short_description'),
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
data.cases = cases;
|
|
145
|
+
})();
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
| Variable | Contents |
|
|
149
|
+
|---|---|
|
|
150
|
+
| `input` | The call's input (pinned, then staged, then the call's own); `{}` on page load. Untrusted |
|
|
151
|
+
| `data` | **Empty on every call.** Mutate it; it's returned to the client. The client's data is never sent back |
|
|
152
|
+
| `options` | The instance's effective options (component defaults overlaid by the placement's) |
|
|
153
|
+
| `component`, `context` | Ids; the portal, page, route params, URL params (`context.client.params`, untrusted), user, panel, variant |
|
|
154
|
+
| `$sp` (also `$rp`) | The server API: `getValue`, `getParameter`, `getRecord`, `canReadRecord`, `getUser`, `addInfoMessage` / `addErrorMessage` / `addSuccessMessage` (shown as toasts), `getWidget` (server-side embeds), `log` |
|
|
155
|
+
| `gs`, `GlideRecordSecure`, … | The normal scoped server APIs, in the scope of the component's application |
|
|
156
|
+
|
|
157
|
+
- Use `GlideRecordSecure` (or `$sp.getRecord` / `$sp.canReadRecord`) so the user's ACLs apply.
|
|
158
|
+
- Store plain values (`gr.getValue(...)`), not GlideElements: `data` is normalized to JSON.
|
|
159
|
+
- The script follows the owning application's JavaScript mode. In ES5 (compatibility) mode only ES5 parses: `var`,
|
|
160
|
+
`function`, no arrows, template literals, `let` / `const` or classes. Check the app before using ES2015+ syntax.
|
|
161
|
+
- Errors become `500 script_error` with your line number, toasted to developers; for the details:
|
|
162
|
+
`rpforge docs read authoring/server-script`.
|
|
163
|
+
- Read [rules.md](rules.md) for the runtime limits (no array spread, sealed `globalThis`, Promise timing).
|
|
164
|
+
|
|
165
|
+
## `options.schema.json` and defaults
|
|
166
|
+
|
|
167
|
+
```json
|
|
168
|
+
{
|
|
169
|
+
"type": "object",
|
|
170
|
+
"properties": {
|
|
171
|
+
"title": { "type": "string", "title": "Title" },
|
|
172
|
+
"limit": { "type": "integer", "title": "Rows", "minimum": 1, "maximum": 50, "default": 10 },
|
|
173
|
+
"density": { "type": "string", "title": "Density", "enum": ["compact", "normal"] },
|
|
174
|
+
"table": { "type": "string", "title": "Table", "x-embed": "server" }
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
- Effective options = `component.json` `defaults` overlaid (shallowly) by the placement's `options`.
|
|
180
|
+
- The designer form supports strings (`enum`, `format: "textarea" | "color" | "url"`), numbers, booleans and arrays of
|
|
181
|
+
objects; anything else is a JSON editor.
|
|
182
|
+
- `"x-presets"`: quick-value buttons (and palette chips for blocks). `"x-css-var": "--acme-cols"`: the option becomes a
|
|
183
|
+
CSS custom property on the placement. `"x-embed": "server"`: only a parent's server script can set it (use it for
|
|
184
|
+
anything that grants authority, like a table or a query).
|
|
185
|
+
|
|
186
|
+
## The host kit and the record primitives
|
|
187
|
+
|
|
188
|
+
Two layers, always:
|
|
189
|
+
|
|
190
|
+
1. **The host kit** (`components:button`, `components:card`, `components:dialog`, `components:select`,
|
|
191
|
+
`components:tabs`, `components:combobox`, `components:icon`, `components:chart`, `components:rich-text-editor`,
|
|
192
|
+
`components:code-editor`, `utilities:react-query`, `utilities:react-table`, `utilities:react-virtual`,
|
|
193
|
+
`utilities:dnd-kit`, `utilities:cn`, …): generic shadcn / Base UI pieces with no domain logic.
|
|
194
|
+
2. **Record primitives** (`components:app/record-form`, `components:app/record-list`, `components:app/field`, …):
|
|
195
|
+
ServiceNow-aware pieces built on the kit. Your own domain pieces belong here too, as your own primitives
|
|
196
|
+
(`components:acme/<key>`), not buried in a widget.
|
|
197
|
+
|
|
198
|
+
The catalog changes with each React Portal release, so look it up on the instance:
|
|
199
|
+
`rpforge components --kind primitive`, `rpforge components get app/record-form`, `rpforge api components:select`,
|
|
200
|
+
`rpforge docs read primitives/overview`, `rpforge docs read runtime-api/host-kit`.
|
|
201
|
+
|
|
202
|
+
Heavy libraries (charts, rich text, code editor) load lazily the first time a component uses them, so portals that
|
|
203
|
+
don't use them pay nothing.
|
|
204
|
+
|
|
205
|
+
## Styling
|
|
206
|
+
|
|
207
|
+
- Tailwind v4 classes are compiled on the server for exactly the classes you use. Theme colors are utilities:
|
|
208
|
+
`bg-background`, `text-foreground`, `bg-card`, `bg-primary text-primary-foreground`, `text-muted-foreground`,
|
|
209
|
+
`border-border`, `bg-destructive`, `text-chart-1`, `bg-success`. `dark:` follows the user's mode.
|
|
210
|
+
- `styles.css`: prefix class names (`acme-cases__row`): every component's CSS shares one shadow root. Use theme tokens
|
|
211
|
+
as `var(--primary)`.
|
|
212
|
+
- Let the root element take the full width of its slot and don't hard-code outer margins: admins style placements
|
|
213
|
+
(padding, background, grid position, classes) in the designer.
|
|
214
|
+
- Floating UI (menus, popovers, dialogs) must render into the overlay layer; the kit's pieces already do.
|