@jskit-ai/agent-docs 0.1.3 → 0.1.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.
Files changed (42) hide show
  1. package/DISTR_AGENT.md +11 -1
  2. package/guide/agent/app-extras/assistant.md +1 -1
  3. package/guide/agent/app-extras/realtime.md +1 -1
  4. package/guide/agent/app-setup/a-more-interesting-shell.md +1 -1
  5. package/guide/agent/app-setup/authentication.md +9 -1
  6. package/guide/agent/app-setup/console.md +1 -1
  7. package/guide/agent/app-setup/database-layer.md +1 -1
  8. package/guide/agent/app-setup/initial-scaffolding.md +1 -1
  9. package/guide/agent/app-setup/multi-homing.md +3 -1
  10. package/guide/agent/app-setup/users.md +1 -1
  11. package/guide/agent/app-setup/working-with-the-jskit-cli.md +1 -1
  12. package/guide/agent/generators/advanced-cruds.md +163 -1
  13. package/guide/agent/generators/crud-generators.md +30 -1
  14. package/guide/agent/generators/intro.md +1 -1
  15. package/guide/agent/generators/ui-generators.md +1 -1
  16. package/guide/agent/index.md +1 -1
  17. package/package.json +1 -1
  18. package/reference/autogen/packages/agent-docs.md +18 -0
  19. package/skills/jskit-review/SKILL.md +12 -2
  20. package/templates/APP_BLUEPRINT.md +9 -0
  21. package/templates/WORKBOARD.md +3 -3
  22. package/templates/app/AGENTS.md +15 -3
  23. package/workflow/bootstrap.md +17 -2
  24. package/workflow/feature-delivery.md +19 -3
  25. package/workflow/review.md +9 -3
  26. package/workflow/scoping.md +10 -1
  27. package/workflow/workboard.md +1 -1
  28. package/guide/human/app-extras/assistant.md +0 -693
  29. package/guide/human/app-extras/realtime.md +0 -268
  30. package/guide/human/app-setup/a-more-interesting-shell.md +0 -732
  31. package/guide/human/app-setup/authentication.md +0 -961
  32. package/guide/human/app-setup/console.md +0 -350
  33. package/guide/human/app-setup/database-layer.md +0 -820
  34. package/guide/human/app-setup/initial-scaffolding.md +0 -753
  35. package/guide/human/app-setup/multi-homing.md +0 -793
  36. package/guide/human/app-setup/users.md +0 -402
  37. package/guide/human/app-setup/working-with-the-jskit-cli.md +0 -1047
  38. package/guide/human/generators/advanced-cruds.md +0 -921
  39. package/guide/human/generators/crud-generators.md +0 -554
  40. package/guide/human/generators/intro.md +0 -107
  41. package/guide/human/generators/ui-generators.md +0 -663
  42. package/guide/human/index.md +0 -37
@@ -1,793 +0,0 @@
1
- # Multi-homing
2
-
3
- Up to this point, the app has had several surfaces, but none of them were workspace-dependent. `home`, `auth`, `account`, and `console` all live outside any workspace slug.
4
-
5
- This chapter changes that. We turn the app into a workspace-aware application and install the packages that add the first real workspace surfaces.
6
-
7
- If you are rebuilding this chapter from scratch, the cleanest setup is to start with a workspace-capable tenancy mode from day 0. If you are literally continuing from the previous chapter, you can still move the existing app from `none` to `personal`, but that retrofit has to be done in the right order.
8
-
9
- ## Tenancy modes
10
-
11
- JSKIT currently accepts three tenancy modes:
12
-
13
- - `none`
14
- - no workspace routing
15
- - no `/w/[workspaceSlug]` surfaces
16
- - useful for a purely global app with no workspace concept
17
- - `personal`
18
- - workspace routing is enabled
19
- - each user gets one auto-provisioned personal workspace
20
- - the workspace slug is derived from the user's identity and treated as immutable
21
- - creating additional workspaces is off by default
22
- - `workspaces`
23
- - workspace routing is enabled
24
- - users can belong to multiple named workspaces
25
- - workspace slugs are user-selected rather than derived from the username
26
- - auto-provisioning is off by default, and self-creation is a separate policy choice
27
-
28
- Both `personal` and `workspaces` are workspace-capable modes, so they allow the workspace package descriptors to install the full workspace scaffold.
29
-
30
- This chapter teaches `personal`, not `workspaces`.
31
-
32
- That is deliberate. `personal` gives the guide a much better first-run experience because the first workspace is auto-provisioned for the user. The app still becomes multi-homing-capable, because invitations and memberships can still put one user in several workspaces at once. The `personal` part only changes how the first workspace is provisioned and how its slug policy works.
33
-
34
- ## Recap from previous chapters
35
-
36
- To recreate the previous chapter's package set in a fresh app that is already ready for workspace routing, run:
37
-
38
- ```bash
39
- SUPABASE_URL=...
40
- SUPABASE_KEY=...
41
- DB_HOST=127.0.0.1
42
- DB_PORT=3306
43
- DB_NAME=exampleapp
44
- DB_USER=exampleapp
45
- DB_PASSWORD=secret
46
-
47
- npx @jskit-ai/create-app exampleapp --tenancy-mode personal
48
- cd exampleapp
49
- npm install
50
-
51
- npx jskit add package shell-web
52
- npx jskit add package auth-provider-supabase-core \
53
- --auth-supabase-url "$SUPABASE_URL" \
54
- --auth-supabase-publishable-key "$SUPABASE_KEY" \
55
- --app-public-url "http://localhost:5173"
56
- npx jskit add bundle auth-base
57
- npx jskit add package database-runtime-mysql \
58
- --db-host "$DB_HOST" \
59
- --db-port "$DB_PORT" \
60
- --db-name "$DB_NAME" \
61
- --db-user "$DB_USER" \
62
- --db-password "$DB_PASSWORD"
63
- npx jskit add package users-web
64
- npx jskit add package console-web
65
- npm install
66
- npm run db:migrate
67
- ```
68
-
69
- If you are already continuing from the previous chapter, you do not need to rebuild the app from scratch. Read the textbox below first, then continue with the workspace package install.
70
-
71
- <DocsTerminalTip label="Important" title="Moving An Existing `none` App To `personal`">
72
- If you followed the guide in order, your existing app still has:
73
-
74
- ```js
75
- config.tenancyMode = "none";
76
- ```
77
-
78
- To move that app to workspace routing safely, do this **before** installing `workspaces-core` or `workspaces-web`:
79
-
80
- 1. Edit `config/public.js` and change:
81
-
82
- ```js
83
- config.tenancyMode = "personal";
84
- ```
85
-
86
- 2. Add `workspaces-core`
87
- 3. Run `npm install`
88
- 4. Add `workspaces-web`
89
- 5. Run `npm install`
90
- 6. Run `npm run db:migrate`
91
-
92
- I checked the two failure modes while updating this chapter.
93
-
94
- - If the app is already in `personal` or `workspaces` mode when you add the workspace packages, JSKIT installs the full workspace scaffold, including:
95
- - `src/pages/w/[workspaceSlug]...`
96
- - `src/components/WorkspaceNotFoundCard.vue`
97
- - `src/composables/useWorkspaceNotFoundState.js`
98
- - the workspace placement entries in `src/placement.js`
99
- - If you add `workspaces-core` and `workspaces-web` while the app is still on `none`, JSKIT installs only the non-gated pieces. The app can still build, but those workspace route files and placements are missing.
100
-
101
- That last part is the trap: simply changing `config.tenancyMode` afterwards and running `npx jskit add package workspaces-core` or `workspaces-web` again does **not** backfill the skipped scaffold.
102
-
103
- If you already installed either workspace package while the app was still on `none`, the clean recovery path is:
104
-
105
- 1. Change `config.tenancyMode` to `"personal"`
106
- 2. Run `npx jskit update package workspaces-core`
107
- 3. Run `npx jskit update package workspaces-web`
108
- 4. Run `npm install`
109
- 5. Run `npm run db:migrate`
110
-
111
- When I tested that recovery path, JSKIT warned that some workspace migrations already existed and skipped re-installing them. That is expected. The important part is that `update package ...` re-applies the gated workspace scaffold after the tenancy mode has been fixed.
112
- </DocsTerminalTip>
113
-
114
- ## Installing the workspace packages
115
-
116
- If your app is already on `tenancyMode = "personal"`, run:
117
-
118
- ```bash
119
- npx jskit add package workspaces-core
120
- npm install
121
- npx jskit add package workspaces-web
122
- npm install
123
- npm run db:migrate
124
- ```
125
-
126
- `workspaces-core` adds the server-side workspace runtime and schema migrations. `workspaces-web` adds the workspace-facing client surfaces, shell placements, and app-owned route files.
127
-
128
- If you want to inspect that package before installing it, this is a very good moment to use the CLI chapter's inspection command:
129
-
130
- ```bash
131
- npx jskit show @jskit-ai/workspaces-web --details
132
- ```
133
-
134
- That output makes the package feel much less mysterious, because it shows the exact workspace shell contributions, settings outlets, client tokens, app-owned file writes, and capability requirements before you mutate the app.
135
-
136
- ## What changes now
137
-
138
- This chapter is where the app stops being a collection of global surfaces and starts supporting workspace-dependent ones.
139
-
140
- ### Two new workspace surfaces appear
141
-
142
- After the install, the app gains:
143
-
144
- - an `app` surface rooted at `/w/[workspaceSlug]`
145
- - an `admin` surface rooted at `/w/[workspaceSlug]/admin`
146
-
147
- These are real surfaces, not only pages.
148
-
149
- - `app` is the generic workspace surface that normal authenticated workspace members can use
150
- - `admin` is the richer workspace administration surface
151
-
152
- That distinction matters.
153
-
154
- The `app` surface is the "normal" workspace area. It is where you would usually put the main member-facing experience for that workspace: dashboards, documents, tasks, project views, customer-facing content, or whatever the ordinary in-workspace product actually is.
155
-
156
- The `admin` surface is where the workspace is managed. It is the natural place for things like:
157
-
158
- - inviting other users into the workspace
159
- - managing members and roles
160
- - editing workspace settings
161
- - running workspace-specific admin tools
162
-
163
- So `admin` is not just "another page." It is the surface where the workspace itself is configured and operated.
164
-
165
- There is also no rule that says every app must use these two surfaces in the same way.
166
-
167
- - In one app, `app` could be the real product and `admin` could be the backend for managing it.
168
- - In another app, `admin` might be where most of the real work happens, while `app` stays minimal or even almost empty.
169
- - In a storefront-style app, `app` could be the workspace's visible shop area and `admin` could be the merchant backend.
170
-
171
- The important point is not the label. The important point is the split:
172
-
173
- - `app` is the general workspace-facing surface
174
- - `admin` is the management and control surface for that workspace
175
-
176
- That is why this chapter feels larger than the previous ones. It is not just adding another route. It is adding a new routing topology.
177
-
178
- ### The shell and account surface gain workspace-aware controls
179
-
180
- The placement registry now grows a workspace selector in the top-left of the shell, a pending-invites cue in the top-right area, and workspace tools in the admin shell. The workspaces package also plugs an `Invites` section into the existing `/account` settings screen through the account-settings extension seam that `users-web` exposes.
181
-
182
- That means the shell itself starts adapting to workspace context.
183
-
184
- - on any authenticated surface, the shell can now expose a workspace selector
185
- - signed-in users can now see a pending-invites cue without `users-web` owning that workspace feature
186
- - on admin workspace surfaces, the shell can also expose workspace-specific tools and settings
187
-
188
- This is the first time the guide shows the shell reacting not just to authentication state, but to workspace state as well.
189
-
190
- ### The database schema grows real multi-workspace tables
191
-
192
- `workspaces-core` adds the schema needed for:
193
-
194
- - workspaces
195
- - workspace memberships
196
- - workspace settings
197
- - workspace invites
198
-
199
- That is why `npm run db:migrate` is required again in this chapter. The workspace runtime is not only client-side routing. It is persistent tenancy data.
200
-
201
- ### Existing surfaces do not disappear
202
-
203
- This is also important to notice:
204
-
205
- - `home` still exists
206
- - `auth` still exists
207
- - `account` still exists
208
- - `console` still exists
209
-
210
- The new workspace surfaces are added on top of the existing app, not instead of it.
211
-
212
- That is exactly what multi-homing should feel like. The app now has both:
213
-
214
- - global surfaces
215
- - workspace-scoped surfaces
216
-
217
- ## What to look at in the browser
218
-
219
- Start both processes again:
220
-
221
- ```bash
222
- npm run dev
223
- npm run server
224
- ```
225
-
226
- After you sign in, the app now has the routing structure needed for workspace-aware paths such as:
227
-
228
- ```text
229
- /w/your-personal-slug
230
- /w/your-personal-slug/admin
231
- ```
232
-
233
- In `personal` mode, the first workspace is auto-provisioned for the signed-in user, so you should have a real workspace route to open immediately after login. Later, if the same user is invited into another workspace, routes such as `/w/acme` can exist alongside that personal workspace too.
234
-
235
- At this stage of the guide, the starter workspace pages are still intentionally simple. That is helpful. It lets you see the new routing and shell topology clearly before later chapters add real modules inside those surfaces.
236
-
237
- The most important new visible ideas are:
238
-
239
- - a workspace slug now appears in the route
240
- - the shell can expose workspace selection and workspace tools
241
- - workspace-dependent surfaces can show a dedicated unavailable-state card when the requested workspace cannot be resolved
242
-
243
- First, even the old global `/home` surface now reacts to workspace state. The selector in the top-left and the invites cue in the top-right come from placement entries and workspace bootstrap context, not from the `home` page itself.
244
-
245
- <figure class="docs-browser-shot">
246
- <div class="docs-browser-shot__bar">
247
- <div class="docs-browser-shot__dots" aria-hidden="true">
248
- <span></span>
249
- <span></span>
250
- <span></span>
251
- </div>
252
- <div class="docs-browser-shot__address">http://localhost:5173/home</div>
253
- </div>
254
- <img
255
- src="/images/guide/multi-homing/multi-homing-shell-controls.png"
256
- alt="Example app home surface after the multi-homing chapter, showing the workspace selector and invites cue in the shell"
257
- />
258
- </figure>
259
-
260
- Then open your personal workspace route. The page itself is deliberately light. `src/pages/w/[workspaceSlug]/index.vue` mostly exists to prove that the `app` surface is now real and ready to host later modules.
261
-
262
- <figure class="docs-browser-shot">
263
- <div class="docs-browser-shot__bar">
264
- <div class="docs-browser-shot__dots" aria-hidden="true">
265
- <span></span>
266
- <span></span>
267
- <span></span>
268
- </div>
269
- <div class="docs-browser-shot__address">http://localhost:5173/w/chiaramobily</div>
270
- </div>
271
- <img
272
- src="/images/guide/multi-homing/multi-homing-workspace-home.png"
273
- alt="Example app workspace home route after the multi-homing chapter"
274
- />
275
- </figure>
276
-
277
- Next open the admin surface for the same workspace. This is the matching pattern on the admin side: `src/pages/w/[workspaceSlug]/admin.vue` is the shell wrapper, `src/pages/w/[workspaceSlug]/admin/index.vue` is the starter page, and the top-right workspace tools button is coming from placements rather than being hand-built into that page file.
278
-
279
- <figure class="docs-browser-shot">
280
- <div class="docs-browser-shot__bar">
281
- <div class="docs-browser-shot__dots" aria-hidden="true">
282
- <span></span>
283
- <span></span>
284
- <span></span>
285
- </div>
286
- <div class="docs-browser-shot__address">http://localhost:5173/w/chiaramobily/admin</div>
287
- </div>
288
- <img
289
- src="/images/guide/multi-homing/multi-homing-workspace-admin.png"
290
- alt="Example app workspace admin route after the multi-homing chapter"
291
- />
292
- </figure>
293
-
294
- Finally open the nested workspace settings route. This is useful to inspect because it shows the container pattern most clearly. `src/pages/w/[workspaceSlug]/admin/workspace/settings.vue` owns the section frame and the child outlet, while the actual settings sub-pages can keep arriving later under that shell.
295
-
296
- <figure class="docs-browser-shot">
297
- <div class="docs-browser-shot__bar">
298
- <div class="docs-browser-shot__dots" aria-hidden="true">
299
- <span></span>
300
- <span></span>
301
- <span></span>
302
- </div>
303
- <div class="docs-browser-shot__address">http://localhost:5173/w/chiaramobily/admin/workspace/settings</div>
304
- </div>
305
- <img
306
- src="/images/guide/multi-homing/multi-homing-workspace-settings.png"
307
- alt="Example app workspace settings shell after the multi-homing chapter"
308
- />
309
- </figure>
310
-
311
- ## What the workspace packages add to the app
312
-
313
- This chapter changes the app in four main places:
314
-
315
- - public config
316
- - surface access policies
317
- - migrations
318
- - workspace surface route files and placements
319
-
320
- ### `config/public.js` changes in a big way
321
-
322
- The first change is the explicit tenancy mode:
323
-
324
- ```js
325
- config.tenancyMode = "personal";
326
- ```
327
-
328
- Then the app gets two new surface definitions:
329
-
330
- ```js
331
- config.surfaceDefinitions.app = {
332
- id: "app",
333
- label: "App",
334
- pagesRoot: "w/[workspaceSlug]",
335
- enabled: true,
336
- requiresAuth: true,
337
- requiresWorkspace: true,
338
- accessPolicyId: "workspace_member",
339
- origin: ""
340
- };
341
-
342
- config.surfaceDefinitions.admin = {
343
- id: "admin",
344
- label: "Admin",
345
- pagesRoot: "w/[workspaceSlug]/admin",
346
- enabled: true,
347
- requiresAuth: true,
348
- requiresWorkspace: true,
349
- accessPolicyId: "workspace_member",
350
- origin: ""
351
- };
352
- ```
353
-
354
- And the app also gains workspace-level feature config:
355
-
356
- ```js
357
- config.workspaceSwitching = true;
358
- config.workspaceInvitations = {
359
- enabled: true,
360
- allowInPersonalMode: true
361
- };
362
- ```
363
-
364
- Those lines are the public contract that tells both client and server, "this app is workspace-aware now."
365
-
366
- ### `config/surfaceAccessPolicies.js` gains `workspace_member`
367
-
368
- The new workspace surfaces use a workspace membership rule:
369
-
370
- ```js
371
- surfaceAccessPolicies.workspace_member = {
372
- requireAuth: true,
373
- requireWorkspaceMembership: true
374
- };
375
- ```
376
-
377
- This is the first time the guide shows a surface guarded not just by auth or a simple flag, but by real workspace membership.
378
-
379
- That is the core idea of multi-homing in JSKIT:
380
-
381
- - the route contains a workspace slug
382
- - the server resolves that workspace
383
- - access depends on whether the current user belongs to it
384
-
385
- ### The migrations now include workspace schema
386
-
387
- After `workspaces-core`, the migration directory grows again with files such as:
388
-
389
- ```text
390
- migrations/
391
- 2026..._workspaces-core-initial-schema.cjs
392
- 2026..._users-core-workspace-settings-single-name-source.cjs
393
- 2026..._users-core-workspaces-drop-color.cjs
394
- ```
395
-
396
- These are the tables and schema changes that make workspace tenancy real in the database.
397
-
398
- That is why the chapter needs another `npm run db:migrate`. Without those tables, the workspace runtime would have routes and UI, but nowhere to persist workspace membership and settings.
399
-
400
- ### The route tree gains workspace-dependent pages
401
-
402
- The app now gets:
403
-
404
- ```text
405
- src/pages/w/[workspaceSlug].vue
406
- src/pages/w/[workspaceSlug]/index.vue
407
- src/pages/w/[workspaceSlug]/admin.vue
408
- src/pages/w/[workspaceSlug]/admin/index.vue
409
- src/pages/w/[workspaceSlug]/admin/members/index.vue
410
- src/pages/w/[workspaceSlug]/admin/workspace/settings.vue
411
- src/pages/w/[workspaceSlug]/admin/workspace/settings/index.vue
412
- ```
413
-
414
- That list shows the first real nested workspace topology.
415
-
416
- - `w/[workspaceSlug].vue` is the `app` surface wrapper
417
- - `w/[workspaceSlug]/index.vue` is the starter landing page for the `app` surface
418
- - `w/[workspaceSlug]/admin.vue` is the `admin` surface wrapper
419
- - `w/[workspaceSlug]/admin/index.vue` is the starter landing page for the `admin` surface
420
- - `w/[workspaceSlug]/admin/members/index.vue` mounts the first real workspace admin client element
421
- - `w/[workspaceSlug]/admin/workspace/settings.vue` is a local section shell for nested workspace settings routes
422
- - `w/[workspaceSlug]/admin/workspace/settings/index.vue` is the default child route for that settings shell
423
-
424
- So the workspace surface model is not only a config concept. It becomes a real file-based routing tree in `src/pages/`.
425
-
426
- These files are intentionally thinner than they look.
427
-
428
- Most of the machinery happens up-hill from them:
429
-
430
- - `config/public.js` defines which surfaces exist and which path roots they own
431
- - `config/surfaceAccessPolicies.js` defines the membership rule that guards them
432
- - `src/placement.js` wires the selector, invites cue, and admin tools into the shell
433
- - `workspaces-core` and `workspaces-web` provide the bootstrap, workspace resolution, permissions, settings, and reusable client elements underneath those routes
434
-
435
- So the `src/pages` files are mostly containers and composition points, not the place where workspace tenancy is implemented.
436
-
437
- Concretely, that route tree works like this:
438
-
439
- - `w/[workspaceSlug].vue` and `w/[workspaceSlug]/admin.vue` are almost pure wrappers. They tag the route with the correct surface id and mount `ShellLayout` plus a child `<RouterView />`.
440
- - `w/[workspaceSlug]/index.vue` and `w/[workspaceSlug]/admin/index.vue` are intentionally simple starter cards. They prove that the new workspace surfaces are live, but they are meant to be replaced by real product modules later.
441
- - `w/[workspaceSlug]/admin/members/index.vue` is still thin, but in a different way: it mostly hands control to a packaged `WorkspaceMembersClientElement`, so the route file stays small while the reusable member-management behavior lives in `workspaces-web`.
442
- - `w/[workspaceSlug]/admin/workspace/settings.vue` is a section shell. It does not own the actual settings fields. It owns the card frame, the left-side settings menu outlet, and the nested `<RouterView />` where child settings pages render.
443
- - `w/[workspaceSlug]/admin/workspace/settings/index.vue` is intentionally almost empty. Its job is to make `/admin/workspace/settings` a real route today and give you a clean place to redirect or add child settings pages later.
444
-
445
- ### Workspace pages are prepared for missing-workspace states
446
-
447
- The starter workspace pages already use a dedicated unavailable-state helper:
448
-
449
- ```vue
450
- <WorkspaceNotFoundCard
451
- v-if="workspaceUnavailable"
452
- :message="workspaceUnavailableMessage"
453
- surface-label="App"
454
- />
455
- ```
456
-
457
- That is worth noticing because it shows that workspace routing is not just string matching on `[workspaceSlug]`. The runtime is expected to decide whether the requested workspace is actually valid and accessible.
458
-
459
- This is another example of the "mostly containers" pattern. The page file does not resolve the workspace itself. It asks the shared `useWorkspaceNotFoundState()` helper for the current workspace-bootstrap status and then swaps between:
460
-
461
- - a shared unavailable card when the workspace is missing or inaccessible
462
- - the local starter content when the workspace context is valid
463
-
464
- So the starter pages already distinguish:
465
-
466
- - valid workspace context
467
- - invalid or inaccessible workspace context
468
-
469
- ### The public workspace client API for custom pages
470
-
471
- At this point in the chapter, it is worth separating two different kinds of client-side helpers:
472
-
473
- - app-owned scaffold helpers written into `src/`
474
- - public package helpers exported by `@jskit-ai/workspaces-web`
475
-
476
- `useWorkspaceNotFoundState()` belongs to the first group. It is an app-owned helper scaffolded into:
477
-
478
- ```text
479
- src/composables/useWorkspaceNotFoundState.js
480
- ```
481
-
482
- That makes it easy to customize locally.
483
-
484
- The main app-author-facing helper exported by `workspaces-web` itself is:
485
-
486
- ```js
487
- import { useWorkspaceRouteContext } from "@jskit-ai/workspaces-web/client/composables/useWorkspaceRouteContext";
488
- ```
489
-
490
- That is the public composable most custom workspace pages should reach for first.
491
-
492
- #### What `workspaces-web` actually exposes publicly on the client side
493
-
494
- Today, the public client surface is intentionally small.
495
-
496
- - `@jskit-ai/workspaces-web/client`
497
- - the package's client runtime registration surface
498
- - exports `clientProviders`, `WorkspacesWebClientProvider`, and `WorkspaceMembersClientElement`
499
- - `@jskit-ai/workspaces-web/client/composables/useWorkspaceRouteContext`
500
- - the main public page-level composable for workspace-aware route context
501
-
502
- That is a useful distinction.
503
-
504
- - `WorkspacesWebClientProvider` and `clientProviders` are runtime wiring, not something a normal page imports.
505
- - `WorkspaceMembersClientElement` is a packaged feature element that a route can render directly.
506
- - `useWorkspaceRouteContext()` is the public helper most app-authored workspace pages will actually use.
507
-
508
- There are other helpers inside the package source, but if they are not exported by the package, treat them as internal implementation details rather than app code API.
509
-
510
- #### What `useWorkspaceRouteContext()` gives you
511
-
512
- The composable returns:
513
-
514
- - `route`
515
- - the live Vue Router route object
516
- - `routePath`
517
- - the normalized runtime pathname
518
- - `currentSurfaceId`
519
- - the resolved current surface id, such as `app` or `admin`
520
- - `workspaceSlugFromRoute`
521
- - the current workspace slug, but only when the current route really belongs to a workspace-dependent surface
522
- - `placementContext`
523
- - the current shell placement/bootstrap context
524
- - `mergePlacementContext`
525
- - the function used to merge new context back into the shell runtime
526
-
527
- For most custom pages, the two values you care about most are:
528
-
529
- - `workspaceSlugFromRoute`
530
- - `currentSurfaceId`
531
-
532
- #### Why use it instead of reading `$route.params.workspaceSlug` directly
533
-
534
- For a very simple page, reading the raw route param can work.
535
-
536
- But `useWorkspaceRouteContext()` is the better default for workspace-aware app code because it does more than "read a param":
537
-
538
- - it resolves the current surface through the shell placement/runtime context
539
- - it normalizes the current route path before extracting anything
540
- - it only returns a workspace slug when the current surface is actually workspace-scoped
541
- - it works the same way on both workspace surfaces, `app` and `admin`
542
-
543
- That means your page logic stays aligned with the same route model that the packaged workspace components use internally.
544
-
545
- In other words:
546
-
547
- - `$route.params.workspaceSlug` is a raw route detail
548
- - `useWorkspaceRouteContext()` is a workspace-aware view of the current route
549
-
550
- #### A concrete custom page example
551
-
552
- Suppose you create a real admin page at:
553
-
554
- ```text
555
- src/pages/w/[workspaceSlug]/admin/reports/index.vue
556
- ```
557
-
558
- and that page needs to:
559
-
560
- - know which workspace it is looking at
561
- - know that it is running on the `admin` surface
562
- - build a workspace-scoped API request or query key
563
-
564
- That is exactly the kind of page `useWorkspaceRouteContext()` is for:
565
-
566
- ```vue
567
- <script setup>
568
- import { computed } from "vue";
569
- import { usePaths } from "@jskit-ai/users-web/client/composables/usePaths";
570
- import { useWorkspaceRouteContext } from "@jskit-ai/workspaces-web/client/composables/useWorkspaceRouteContext";
571
-
572
- const { workspaceSlugFromRoute, currentSurfaceId } = useWorkspaceRouteContext();
573
- const paths = usePaths();
574
-
575
- const reportsApiPath = computed(() => {
576
- if (!workspaceSlugFromRoute.value) {
577
- return "";
578
- }
579
-
580
- return paths.api("/reports", {
581
- params: {
582
- workspaceSlug: workspaceSlugFromRoute.value
583
- }
584
- });
585
- });
586
-
587
- const queryKey = computed(() => ([
588
- "workspace-reports",
589
- currentSurfaceId.value,
590
- workspaceSlugFromRoute.value
591
- ]));
592
- </script>
593
- ```
594
-
595
- That pattern is intentionally boring in the right way.
596
-
597
- - the page does not hard-code path parsing rules itself
598
- - the page gets a normalized workspace slug from the public workspace helper
599
- - the query key can still distinguish between `app` and `admin` when needed
600
-
601
- The same composable works just as well in a custom workspace app page under:
602
-
603
- ```text
604
- src/pages/w/[workspaceSlug]/index.vue
605
- ```
606
-
607
- or any later child page below that surface.
608
-
609
- #### When you need the rest of the returned context
610
-
611
- Most custom pages only need:
612
-
613
- - `workspaceSlugFromRoute`
614
- - `currentSurfaceId`
615
- - maybe `route`
616
-
617
- The other returned values are there for more advanced cases.
618
-
619
- - `placementContext` matters when a page needs to read the current shell/bootstrap context directly, for example available workspaces or current permissions already in the shell state.
620
- - `mergePlacementContext` is for pages that need to push refreshed workspace data back into the shell runtime after a fetch or save.
621
-
622
- That second case is real, but it is more advanced. It is what packaged elements such as the workspace settings client use when they need the shell's current workspace badge, selector state, or permissions to refresh after a change.
623
-
624
- For normal custom page code, you usually do **not** start there. Start with `workspaceSlugFromRoute`.
625
-
626
- ### `src/placement.js` becomes workspace-aware
627
-
628
- The workspace packages append a new block of placements:
629
-
630
- ```js
631
- addPlacement({
632
- id: "workspaces.profile.menu.surface-switch",
633
- target: "auth-profile-menu:primary-menu",
634
- surfaces: ["*"],
635
- order: 100,
636
- componentToken: "workspaces.web.profile.menu.surface-switch-item",
637
- when: ({ auth }) => Boolean(auth?.authenticated)
638
- });
639
-
640
- addPlacement({
641
- id: "workspaces.workspace.selector",
642
- target: "shell-layout:top-left",
643
- surfaces: ["*"],
644
- order: 200,
645
- componentToken: "workspaces.web.workspace.selector",
646
- props: {
647
- allowOnNonWorkspaceSurface: true,
648
- targetSurfaceId: "app"
649
- },
650
- when: ({ auth }) => {
651
- return Boolean(auth?.authenticated);
652
- }
653
- });
654
-
655
- addPlacement({
656
- id: "workspaces.account.invites.cue",
657
- target: "shell-layout:top-right",
658
- surfaces: ["*"],
659
- order: 850,
660
- componentToken: "local.main.account.pending-invites.cue",
661
- when: ({ auth }) => Boolean(auth?.authenticated)
662
- });
663
-
664
- addPlacement({
665
- id: "workspaces.workspace.tools.widget",
666
- target: "shell-layout:top-right",
667
- surfaces: ["admin"],
668
- order: 900,
669
- componentToken: "workspaces.web.workspace.tools.widget"
670
- });
671
-
672
- addPlacement({
673
- id: "workspaces.workspace.menu.workspace-settings",
674
- target: "workspace-tools:primary-menu",
675
- surfaces: ["admin"],
676
- order: 100,
677
- componentToken: "workspaces.web.workspace-settings.menu-item"
678
- });
679
-
680
- addPlacement({
681
- id: "workspaces.workspace.menu.members",
682
- target: "workspace-tools:primary-menu",
683
- surfaces: ["admin"],
684
- order: 200,
685
- componentToken: "workspaces.web.workspace-members.menu-item"
686
- });
687
- ```
688
-
689
- That one block explains a lot of the new shell behavior.
690
-
691
- - the authenticated profile menu can now switch into workspace surfaces
692
- - the top-left area now has a workspace selector
693
- - the top-right area can show a pending-invites cue
694
- - the admin surface gets workspace tools in the top-right area
695
- - the admin workspace settings menu is now another nested placement host with both `Settings` and `Members`
696
-
697
- So the placement system from the shell chapter is still doing the same job as before. The app just has a richer routing and tenancy context now.
698
-
699
- ### The local client provider gets one more app-owned token
700
-
701
- `workspaces-web` also appends an app-owned component registration:
702
-
703
- ```js
704
- registerMainClientComponent("local.main.account.pending-invites.cue", () => AccountPendingInvitesCue);
705
- ```
706
-
707
- That is the pending-invites cue used in the shell when workspace invitations exist.
708
-
709
- This is worth noticing because it follows the same app-owned token pattern the guide has shown before:
710
-
711
- - the package installs an app-owned component file
712
- - the app-local provider publishes it under a stable token
713
- - placements can then render it through the shell
714
-
715
- ## Under the hood
716
-
717
- ### `workspaces-core` plugs into the users profile-sync registry
718
-
719
- There is also an important server-side integration point that is easy to miss if you only look at routes and pages.
720
-
721
- In the previous chapter, `users-core` introduced the tagged profile-sync lifecycle registry that runs after a JSKIT user record has been synchronized from auth. `workspaces-core` uses that seam by registering a contributor:
722
-
723
- ```js
724
- registerProfileSyncLifecycleContributor(app, "workspaces.core.profileSyncLifecycleContributor", (scope) => {
725
- const workspaceService = scope.make("workspaces.service");
726
-
727
- return Object.freeze({
728
- contributorId: "workspaces.core.profileSync",
729
- order: 100,
730
- async afterIdentityProfileSynced({ profile, created, options } = {}) {
731
- if (!created || !profile || typeof workspaceService?.provisionWorkspaceForNewUser !== "function") {
732
- return;
733
- }
734
-
735
- await workspaceService.provisionWorkspaceForNewUser(profile, options);
736
- }
737
- });
738
- });
739
- ```
740
-
741
- That means the workspace package does not need to patch auth directly to learn that a user was added. It listens through the `users-core` lifecycle registry instead.
742
-
743
- For this chapter's `tenancyMode = "personal"` setup, that contributor now does real work. When a brand-new JSKIT user is synchronized from auth, `workspaces-core` uses the lifecycle seam to provision that user's first personal workspace automatically.
744
-
745
- - `users-core` owns the "user was synchronized" lifecycle
746
- - `workspaces-core` subscribes to that lifecycle through the registry
747
- - tenancy policy decides whether the workspace layer provisions a personal workspace automatically
748
-
749
- So even in this chapter, the package boundary is already correct: users owns user creation/sync, and workspaces reacts through an extension point.
750
-
751
- ### Why this chapter is the real routing pivot
752
-
753
- Earlier chapters added features inside a flat top-level app.
754
-
755
- This chapter is different. It changes the shape of the app itself.
756
-
757
- Before:
758
-
759
- - global surfaces only
760
- - no workspace slug in routes
761
- - no workspace membership checks
762
-
763
- After:
764
-
765
- - global surfaces still exist
766
- - workspace-scoped surfaces now exist too
767
- - the shell can navigate between workspaces
768
- - access to some surfaces now depends on workspace membership
769
-
770
- That is why multi-homing deserves its own chapter. It is not just another feature package. It is the moment the app becomes tenancy-aware.
771
-
772
- ## Summary
773
-
774
- This chapter is the real routing and tenancy pivot in the guide.
775
-
776
- - the app now uses `tenancyMode = "personal"`
777
- - `workspaces-core` added the persistent schema and server runtime for workspaces
778
- - `workspaces-web` added the first workspace-scoped surfaces, shell controls, and the workspace-owned account invites extension
779
-
780
- At the end of this chapter, the app now has both:
781
-
782
- - global surfaces such as `home`, `auth`, `account`, and `console`
783
- - workspace-scoped surfaces such as `/w/[workspaceSlug]` and `/w/[workspaceSlug]/admin`
784
-
785
- That is the most important mental shift to keep:
786
-
787
- - earlier chapters added features inside one global app shell
788
- - this chapter changed the topology of the app itself
789
-
790
- From here on, later modules are no longer only adding pages or widgets. They can add features inside either:
791
-
792
- - the global surfaces
793
- - the workspace-specific surfaces