@fluid-app/fluid-cli-portal 0.1.61 → 0.1.62

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.
Files changed (26) hide show
  1. package/authoring/commands.md +242 -0
  2. package/dist/{backend-dev-plugin-20fLk-4t.mjs → backend-dev-plugin-z9IZCHaY.mjs} +2 -2
  3. package/dist/{backend-dev-plugin-20fLk-4t.mjs.map → backend-dev-plugin-z9IZCHaY.mjs.map} +1 -1
  4. package/dist/index.d.mts +571 -423
  5. package/dist/index.d.mts.map +1 -1
  6. package/dist/index.mjs +17 -15
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/{portal-dev-plugin-5BbRo9QT.mjs → portal-dev-plugin-2jZODDsX.mjs} +2 -2
  9. package/dist/{portal-dev-plugin-5BbRo9QT.mjs.map → portal-dev-plugin-2jZODDsX.mjs.map} +1 -1
  10. package/dist/{portal-widget-dev-plugin-NBHcnvFJ.mjs → portal-widget-dev-plugin-Dyp2bVy7.mjs} +3 -3
  11. package/dist/{portal-widget-dev-plugin-NBHcnvFJ.mjs.map → portal-widget-dev-plugin-Dyp2bVy7.mjs.map} +1 -1
  12. package/dist/{pull-BlG6pMwC.mjs → pull-BWnby_pY.mjs} +6287 -2908
  13. package/dist/{pull-BlG6pMwC.mjs.map → pull-BWnby_pY.mjs.map} +1 -1
  14. package/dist/{src-2znVq55R.mjs → src-CQ24GVe6.mjs} +7 -1
  15. package/dist/src-CQ24GVe6.mjs.map +1 -0
  16. package/dist/vite-plugin.mjs +4 -4
  17. package/package.json +8 -7
  18. package/templates/base/.gitignore.template +3 -0
  19. package/templates/base/AGENTS.md +40 -41
  20. package/templates/base/skills/fluid-portal-authoring/SKILL.md +37 -428
  21. package/templates/base/skills/fluid-portal-authoring/references/portal-json.md +46 -0
  22. package/templates/base/skills/fluid-portal-authoring/references/widgets-and-runtime.md +57 -0
  23. package/templates/base/skills/fluid-portal-authoring/references/workflows.md +56 -0
  24. package/templates/starter/.env.example +9 -0
  25. package/templates/starter/README.md.template +99 -169
  26. package/dist/src-2znVq55R.mjs.map +0 -1
@@ -0,0 +1,57 @@
1
+ # Widgets and runtime choices
2
+
3
+ ## Built-in widgets
4
+
5
+ Use the current portal schema and builder catalog for the complete built-in
6
+ widget set and each widget's props. Do not maintain category, type, or prop
7
+ lists in this guide. An unregistered type renders no widget.
8
+
9
+ ## Company widget package
10
+
11
+ Use a company widget package for Remote DOM UI authored in a portal project.
12
+ Author it under `src/widgets/` and register it in `src/widgets.config.ts`.
13
+ Packages can use serializable props, declared host portal functions, and
14
+ approved public HTTP access. `fluid portal deploy` publishes these widget
15
+ artifacts.
16
+
17
+ ## Standalone Droplet widget package
18
+
19
+ Use the standalone widget project and `fluid widget publish` for a package
20
+ associated with an existing Droplet. Do not mix its
21
+ `fluid.widget.config.ts` layout with the company widget package layout.
22
+
23
+ ## Server application
24
+
25
+ Use a Mist application or another server component for secrets, OAuth,
26
+ webhooks, private APIs, background work, and other server behavior. Remote DOM
27
+ workers receive no host cookies, storage, API client, or credentials. Do not
28
+ invent an embed URL or iframe contract. Use only routes and integration
29
+ contracts supplied by the application.
30
+
31
+ ## Network access
32
+
33
+ Widget network access requires the declared `networkAccess` capability and an
34
+ author-approved placement grant. The builder shows a warning when the widget
35
+ is added and keeps a customization banner visible while the capability is
36
+ present. The grant is bound to the exact package and capability versions. A
37
+ change invalidates the grant and requires approval again. In the CLI, `--yes`
38
+ does not approve this capability; a non-interactive push needs
39
+ `--allow-network-widgets`.
40
+
41
+ Granted requests use native fetch from the worker origin. Fluid does not add
42
+ credentials, cookies, tokens, or headers. The widget's own `RequestInit`
43
+ values, including credential mode, remain in effect.
44
+
45
+ The runtime reference owns the exact blocked-destination and ambient-API
46
+ contract. Native fetch redirects and DNS results are not revalidated, so
47
+ approval is a package trust decision. Any portal data exposed to the widget can
48
+ be sent to an external service, and worker isolation does not protect the
49
+ browser reputation of `*.fluid.app`.
50
+
51
+ ## Theme behavior
52
+
53
+ Built-in and third-party widgets should follow the active theme. Prefer
54
+ semantic colors, typography, spacing, radii, borders, focus, and chart tokens.
55
+ For widget property schemas, use `colorSelect` so authors choose a semantic
56
+ token. The legacy `color` field is deprecated. Do not add arbitrary colors or
57
+ styling properties when the theme engine already expresses the intended role.
@@ -0,0 +1,56 @@
1
+ # Preview, synchronization, and deployment
2
+
3
+ ## Local preview
4
+
5
+ Use `pnpm dev`, which runs `fluid portal dev`. The CLI reads the local portal
6
+ resources, pulls when `portal/` is missing, and installs its Vite integration.
7
+ Do not replace it with bare Vite for portal definition work.
8
+
9
+ When `VITE_API_URL` is unset, development resolves the signed-in company and
10
+ proxies `/api` to its tenant portal host. The override changes routing, not
11
+ authentication. Localhost does not have the HttpOnly member handoff cookie, so
12
+ authenticated screens can return HTTP 401.
13
+
14
+ Preview can skip malformed JSON. It preserves unresolved navigation entries
15
+ without attaching a screen ID. It selects the profile marked `default: true`,
16
+ or the first profile when none is marked default, and does not reproduce every
17
+ production permission decision.
18
+
19
+ ## Pull, push, and versions
20
+
21
+ Use the installed command reference for the complete command tree, arguments,
22
+ options, and defaults. Pull reads the remote working definition, push writes
23
+ the working definition, and version activation changes the live definition.
24
+ Treat those as separate effects even when one command can combine phases.
25
+
26
+ `--yes` does not approve a newly network-enabled widget. Use interactive
27
+ approval or add `--allow-network-widgets` after package review.
28
+
29
+ Push writes screens and themes, then navigations, then profiles. A failed phase
30
+ skips later phases. Successful resources can advance their sync snapshot, so
31
+ fix the reported phase and rerun instead of assuming the entire operation was
32
+ rolled back.
33
+
34
+ ## Deployment boundaries
35
+
36
+ - `pnpm build` creates portal application assets in `dist/`.
37
+ - `.github/workflows/deploy.yml` uploads those assets to the configured CDN.
38
+ - `fluid portal deploy` builds and publishes company widget artifacts from
39
+ `src/widgets.config.ts`.
40
+ - `fluid widget publish` publishes a standalone Droplet widget package.
41
+
42
+ Portal deploy does not push portal JSON, activate a portal version, publish
43
+ standalone widgets, or upload the portal application bundle.
44
+
45
+ Read the generated workflow and its adjacent environment template for the
46
+ complete deployment-variable contract. Do not copy that list into this skill.
47
+
48
+ ## Recovery
49
+
50
+ - Authentication failure: correct the selected profile or token and retry.
51
+ - Invalid JSON or reference: fix the named local resource and validate again.
52
+ - Remote drift: preserve local edits, pull, reapply the intended diff, and
53
+ push again.
54
+ - Failed activation: inspect remote version state before creating another
55
+ version.
56
+ - Another machine: use `fluid portal clone <app-name>`, then pull.
@@ -5,7 +5,16 @@
5
5
  # portal-member handoff session.
6
6
  # VITE_API_URL=
7
7
 
8
+ # Optional: production asset base used by Vite builds.
9
+ # The included deployment workflow sets this from CDN_HOSTNAME.
10
+ # VITE_ASSET_BASE=
11
+
12
+ # Optional: override the API base used by Fluid CLI commands.
13
+ # FLUID_API_BASE=
14
+
8
15
  # Optional: override the Fluid CLI auth token for this project.
9
16
  # Takes effect when running `pnpm pull`, `pnpm push`, etc.
10
17
  # Alternatively, set the "profile" field in .fluidrc (committed to the repo).
18
+ # FLUID_API_TOKEN=
19
+ # Legacy token name retained for compatibility:
11
20
  # FLUID_TOKEN=
@@ -1,18 +1,12 @@
1
1
  # {{projectName}}
2
2
 
3
- A Fluid portal shell built with `@fluid-app/portal-sdk` and the Fluid portal CLI.
3
+ A Fluid portal shell, local portal-definition workspace, and optional company
4
+ Remote DOM widget package.
4
5
 
5
- This starter is designed for the Fluid OS definition workflow: pull the portal definition into local JSON, edit `portal/`, push the working/draft definition back to Fluid OS, then create and activate a version when it should go live.
6
+ ## Start development
6
7
 
7
- ## What's included
8
-
9
- - **Portal shell** — Vite builds the hosted SDK shell assets.
10
- - **Portal definition sync** — `pnpm pull` and `pnpm push` manage local Fluid OS JSON under `portal/`.
11
- - **Deployment workflow** — GitHub Actions can build and upload the hosted shell assets in `dist/`.
12
- - **Widget authoring support** — `pnpm widget:create <name>` scaffolds company-owned portal widgets.
13
- - **AI authoring kit** — generated `AGENTS.md`, `CLAUDE.md`, `.agents/skills/...`, and `.claude/skills/...` files explain the supported portal and widget workflows.
14
-
15
- ## Quick start
8
+ Requirements: Node.js, pnpm, and a Fluid CLI login or API token for remote
9
+ portal operations.
16
10
 
17
11
  ```bash
18
12
  pnpm install
@@ -20,178 +14,114 @@ pnpm pull
20
14
  pnpm dev
21
15
  ```
22
16
 
23
- Open the local URL printed by Vite, usually [http://localhost:5173](http://localhost:5173).
24
-
25
- Useful commands:
26
-
27
- ```bash
28
- pnpm dev # Pull missing portal JSON and start the portal dev server
29
- pnpm build # TypeScript build plus production bundle
30
- pnpm preview # Preview dist locally
31
- pnpm typecheck # TypeScript checks
32
- pnpm lint # OxLint
33
- pnpm pull # fluid portal pull
34
- pnpm push # fluid portal push
35
- pnpm widget:create <name> # scaffold a company-owned portal widget
36
- ```
37
-
38
- When `VITE_API_URL` is unset, `fluid portal dev` resolves the signed-in
39
- company and proxies `/api` to its tenant BFF at
40
- `https://<subdomain>.portal.fluid.app`. Set `VITE_API_URL` in `.env` only when
41
- you need a different API host. The override changes routing, not
42
- authentication.
43
-
44
- Local preview always serves your local `portal/` manifest, custom pages, and
45
- navigation. Built-in screens that load member data also require the
46
- `portal_tenant_user_id` session cookie created by the production/Rails handoff.
47
- A direct localhost preview cannot create or read that HttpOnly tenant cookie,
48
- so Shop, Orders, Contacts, and other member-data screens may return HTTP 401 or
49
- remain in an unauthenticated state. Do not treat persistent skeletons as proof
50
- that authenticated data works; verify those screens through a real tenant
51
- handoff environment.
52
-
53
- ## Project structure
54
-
55
- ```text
56
- .
57
- ├── AGENTS.md # AI-agent guidance
58
- ├── CLAUDE.md # Bridge to AGENTS.md
59
- ├── .agents/skills/fluid-portal-authoring/ # Portal sync workflow skill
60
- ├── .agents/skills/fluid-widget-authoring/ # Widget authoring skill
61
- ├── .claude/skills/fluid-portal-authoring/ # Claude-compatible copy
62
- ├── .claude/skills/fluid-widget-authoring/ # Claude-compatible copy
63
- ├── .github/workflows/deploy.yml # Hosted shell asset deployment
64
- ├── src/
65
- │ ├── main.tsx # createPortal bootstrap
66
- │ ├── index.css # Tailwind and SDK globals
67
- │ ├── portal.config.ts # SDK custom-page integration
68
- │ ├── widgets.config.ts # Remote DOM widget packages
69
- │ └── widgets/ # Created by pnpm widget:create
70
- ├── portal/ # Created/refreshed by fluid portal pull
71
- └── .portal-sync/ # Generated sync metadata
72
- ```
73
-
74
- ## Supported portal authoring workflow
75
-
76
- ### 1. Pull remote Fluid OS definitions
77
-
78
- ```bash
79
- pnpm pull
80
- ```
81
-
82
- This runs `fluid portal pull` and writes `portal/` plus `.portal-sync/`.
83
-
84
- - `portal/` contains local JSON for Fluid OS resources such as screens, themes, navigations, profiles, and definition metadata.
85
- - `.portal-sync/` contains generated sync state for future diffs. Do not edit it by hand.
86
-
87
- Pull before editing unless you intentionally want to work from the current local JSON.
88
-
89
- ### 2. Edit `portal/` JSON
90
-
91
- Make portal definition changes inside `portal/`.
92
-
93
- Guidelines:
94
-
95
- - Keep JSON valid and deterministic.
96
- - Preserve stable IDs, slugs, and cross-resource references unless intentionally changing them.
97
- - Update related files together when a resource reference changes.
98
- - Do not invent unsupported fields. Match the shapes produced by `pnpm pull`.
99
- - Keep changes small enough to review.
100
-
101
- ### 3. Validate locally
102
-
103
- Run checks that match the change:
17
+ `pnpm dev` runs `fluid portal dev`, normally at http://localhost:5173. When
18
+ `portal/definition.json` is absent, it pulls the linked working definition
19
+ before starting. Pass `-- --skip-pull` only when the missing local definition
20
+ is intentional. The CLI installs portal JSON and widget-development Vite
21
+ plugins; bare Vite does not provide the same preview.
22
+
23
+ Localhost does not receive the production HttpOnly member handoff cookie.
24
+ Authenticated screens can return HTTP 401 even when local JSON and custom pages
25
+ render correctly.
26
+
27
+ ## Project map
28
+
29
+ | Path | Owner and lifecycle |
30
+ | --- | --- |
31
+ | `.fluidrc` | Author-owned link to the remote portal definition. Change only when intentionally relinking. |
32
+ | `.env.example` | Committed environment template. Copy values to `.env` or `.env.local`; do not put secrets in the example. |
33
+ | `.env`, `.env.local` | Local credentials and overrides. Never commit. |
34
+ | `.gitignore` | Source-control exclusions for local, generated, and secret files. |
35
+ | `.oxlintrc.json` | Generated lint configuration. Change only when project lint policy changes. |
36
+ | `package.json` | Project scripts and dependencies. Author-owned after scaffold creation. |
37
+ | lockfile | Dependency resolution. Commit when dependency changes are intentional. |
38
+ | `tsconfig.json`, `vite.config.ts` | TypeScript and Vite build configuration. |
39
+ | `index.html` | Vite HTML entry and portal mount element. |
40
+ | `README.md` | Human setup, lifecycle, and recovery guidance. |
41
+ | `AGENTS.md`, `CLAUDE.md` | Root coding-agent guidance. `CLAUDE.md` points to the canonical `AGENTS.md`. |
42
+ | `portal/definition.json` | Pulled or author-edited portal metadata. Its `$schema` owns valid fields. |
43
+ | `portal/screens/` | Local screen resources. File names are screen slugs. |
44
+ | `portal/navigations/` | Local web or mobile navigation resources. References use file slugs. |
45
+ | `portal/profiles/` | Profile matching and navigation/theme assignments. |
46
+ | `portal/themes/` | Complete theme resources. Partial theme configs are invalid. |
47
+ | `.portal-sync/` | Pull/push snapshots used for drift and diff calculation. Generated; never edit or commit. |
48
+ | `src/main.tsx` | Portal shell entry. |
49
+ | `src/portal.config.ts` | Custom React page registration and portal shell configuration. |
50
+ | `src/widgets.config.ts` | Company widget package registration for development and `fluid portal deploy`. |
51
+ | `src/widgets/` | Company Remote DOM widget source when present. |
52
+ | `src/index.css` | Portal shell styling. Use portal semantic theme tokens. |
53
+ | `src/vite-env.d.ts` | Vite environment type declarations. |
54
+ | `.github/workflows/deploy.yml` | CDN build and shell-asset deployment workflow. |
55
+ | `.agents/skills/fluid-portal-authoring/` | Portal task procedures and reference guidance. |
56
+ | `.agents/skills/fluid-widget-authoring/` | Widget task procedures and reference guidance. |
57
+ | `.claude/skills/` | Compatibility view of the same skills. Do not maintain divergent instructions. |
58
+ | `dist/` | Generated portal shell assets from `pnpm build`. |
59
+ | `.fluid/widget-dist/` | Generated company widget publication artifacts. |
60
+ | `.fluid/widget-build/`, `.fluid/tmp/` | Generated temporary widget build state. |
61
+ | `.fluid-portal-scaffold-pending` | Transient create/clone marker used during interrupted scaffolds. |
62
+ | `node_modules/` | Installed dependencies. Generated. |
63
+
64
+ ## Environment
65
+
66
+ | Variable | Use |
67
+ | --- | --- |
68
+ | `VITE_API_URL` | Optional browser BFF override. When absent, dev resolves the signed-in company and proxies `/api` to its tenant portal host. |
69
+ | `VITE_ASSET_BASE` | Production base URL for portal shell assets. |
70
+ | `FLUID_API_BASE` | Optional Fluid CLI API-base override. |
71
+ | `FLUID_API_TOKEN` | Fluid CLI token. The older `FLUID_TOKEN` name is also accepted. |
72
+
73
+ ## Edit, validate, and review
74
+
75
+ Edit only the required resources under `portal/`. Follow each file's `$schema`.
76
+ The file name, not the display name, is the slug used by navigation, profiles,
77
+ and theme references. Use each resource's schema for the exact widget-tree and
78
+ cross-reference contract.
104
79
 
105
80
  ```bash
106
81
  pnpm typecheck
107
82
  pnpm lint
108
83
  pnpm build
84
+ pnpm exec fluid portal doctor
85
+ git diff
109
86
  ```
110
87
 
111
- For visual/content changes, use local preview:
112
-
113
- ```bash
114
- pnpm dev
115
- ```
116
-
117
- Expected result: the portal CLI pulls the definition when `portal/` is missing, then starts the shell against the local portal JSON. Use this command instead of bare `vite` so the pull and manifest preflight run.
118
-
119
- ### 4. Push local definition changes
120
-
121
- ```bash
122
- pnpm push
123
- ```
124
-
125
- This runs `fluid portal push`, compares local `portal/` JSON against sync state, and updates the remote working/draft definition.
126
-
127
- Push does **not** publish changes live by itself.
128
-
129
- ### 5. Publish a live Fluid OS version
130
-
131
- When the pushed working/draft definition is ready for users:
132
-
133
- ```bash
134
- pnpm exec fluid portal version create --activate
135
- ```
88
+ Before a remote write, run `pnpm pull` when the remote working definition may
89
+ have changed. If local and remote changes conflict, preserve local edits, pull
90
+ the current state, reapply the intended change, and review the new diff.
136
91
 
137
- Only run this when activation is intended. If publishing needs content, design, or release approval, stop and ask first.
92
+ ## Push and activate
138
93
 
139
- ## Command boundaries
94
+ Push validates and writes the remote working definition. It writes resource
95
+ groups in phases; an earlier group can succeed before a later group fails. Fix
96
+ the reported phase and rerun after checking remote and `.portal-sync/` state.
140
97
 
141
- Do not mix these up:
98
+ Activation is separate. `fluid portal push --yes --activate` creates and
99
+ activates a live version only after every push phase succeeds. Do not activate
100
+ unless the task authorizes a live release.
142
101
 
143
- - `fluid portal pull` downloads the remote portal definition into `portal/`.
144
- - `fluid portal push` syncs local `portal/` JSON to the remote working/draft definition.
145
- - `fluid portal version create --activate` makes the remote working/draft definition live.
146
- - `pnpm build` creates hosted shell assets in `dist/`.
147
- - GitHub Actions deploys hosted shell assets from `dist/`.
148
- - `fluid portal deploy` publishes company-owned widget runtime artifacts. It does not push portal JSON and does not upload hosted shell assets.
102
+ A network-enabled third-party widget requires interactive approval. In a
103
+ non-interactive run, add `--allow-network-widgets`; `--yes` alone does not grant
104
+ network access. The grant is exact to package ID, package version, and
105
+ capability version and becomes stale when any value changes.
149
106
 
150
- ## Widget work
107
+ ## Build and deployment boundaries
151
108
 
152
- Company-owned portal widgets are supported through the portal widget scaffold:
109
+ - `pnpm build` creates portal shell assets in `dist/`.
110
+ - `.github/workflows/deploy.yml` uploads `dist/` to GCS and invalidates Cloud
111
+ CDN. Configure `GCP_PROJECT`, `GCS_BUCKET`, `CDN_URL_MAP`, `CDN_HOSTNAME`,
112
+ `CDN_INVALIDATION_PATH`, and repository secret `GCP_SA_JSON`.
113
+ - `fluid portal deploy` builds and publishes company widget runtime artifacts
114
+ from `src/widgets.config.ts` through `.fluid/widget-dist/`.
153
115
 
154
- ```bash
155
- pnpm widget:create stock-ticker
156
- # or
157
- pnpm exec fluid portal widget create stock-ticker
158
- ```
116
+ `fluid portal deploy` does not push portal JSON, activate a portal version, or
117
+ upload the portal shell. The GitHub workflow does not publish portal JSON or
118
+ widget package versions.
159
119
 
160
- The scaffold writes widget source under `src/widgets/<name>/` and registers its package in `src/widgets.config.ts`. Portal pages remain separate in `src/portal.config.ts`. Then use the generated widget authoring skill:
120
+ ## Detailed guidance
161
121
 
122
+ - `.agents/skills/fluid-portal-authoring/SKILL.md`
162
123
  - `.agents/skills/fluid-widget-authoring/SKILL.md`
163
- - `.claude/skills/fluid-widget-authoring/SKILL.md`
164
-
165
- That skill covers canonical Remote DOM packages, property schemas, theme variables, runtime CSS, validation, build, and publish workflows.
166
-
167
- ## Hosted shell deployment
168
-
169
- The included GitHub Actions workflow builds the portal and uploads `dist/` to Google Cloud Storage plus Cloud CDN.
170
-
171
- 1. Push to `main` or run the workflow manually.
172
- 2. The workflow runs `pnpm build`.
173
- 3. It syncs `dist/` to `gs://portals-cdn/{{projectName}}/assets/`.
174
- 4. It invalidates the CDN cache for this portal's asset prefix.
175
-
176
- Setup:
177
-
178
- 1. Create a GCP service account with Storage Object Admin and Compute Load Balancer Admin roles.
179
- 2. Add the service account JSON key as a GitHub Actions secret named `GCP_SA_JSON`.
180
- 3. Set `CDN_HOSTNAME` in `.github/workflows/deploy.yml` to your Cloud CDN load balancer domain.
181
- 4. Update `GCP_PROJECT` and `CDN_URL_MAP` if your project differs from the defaults.
182
-
183
- ## AI authoring kit
184
-
185
- Generated projects include portable guidance for AI coding tools:
186
-
187
- - `AGENTS.md` — canonical project instructions.
188
- - `CLAUDE.md` — plain-file bridge to `AGENTS.md`.
189
- - `.agents/skills/fluid-portal-authoring/SKILL.md` — portal pull/edit/push/version workflow.
190
- - `.agents/skills/fluid-widget-authoring/SKILL.md` — widget authoring and validation workflow.
191
- - `.claude/skills/...` — Claude-compatible copies generated from the same template skill files.
192
-
193
- ## Learn more
194
-
195
- - Fluid Commerce Documentation: https://docs.fluidcommerce.com
196
- - Vite Documentation: https://vite.dev
197
- - React Documentation: https://react.dev
124
+ - Installed portal API contract:
125
+ `node_modules/@fluid-app/portal-sdk/authoring/portal-api/api.md`
126
+ - Installed portal command contract:
127
+ `node_modules/@fluid-app/fluid-cli-portal/authoring/commands.md`