@happyvertical/smrt-template-sveltekit 0.43.4 → 0.43.5

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/AGENTS.md CHANGED
@@ -16,7 +16,8 @@ It is the ground-up alternative to `smrt-saas-starter`.
16
16
  - Node `>=24.18.0`; pnpm `10.34.4` via `packageManager` and `engines`.
17
17
  - Directly used `@happyvertical/smrt-*` packages share one current release range.
18
18
  - `@happyvertical/smrt-cli` is a direct dev dependency because scripts/docs use
19
- its binary. `@happyvertical/smrt-web` stays opt-in until a page imports it.
19
+ its binary. The template includes `@happyvertical/smrt-web` because the root
20
+ Provider wires the generated read-only WebMCP definitions for every page.
20
21
  - The generated MCP server resolves its imports from the scaffolded app, not
21
22
  from the CLI, so every specifier `generate-mcp` emits must be declared here.
22
23
  `@modelcontextprotocol/server` (plus its `/stdio` subpath),
@@ -50,8 +51,10 @@ It is the ground-up alternative to `smrt-saas-starter`.
50
51
  exact permission snapshot.
51
52
  - The root layout uses Provider, the current smrt-ui ThemeProvider, AdminShell,
52
53
  and a small explicit TenantNav. Generated REST routes do not imply page routes.
53
- - WebMCP and live browser data examples are opt-in per page and must seed live
54
- collections from SSR `initialData` to avoid a duplicate first request.
54
+ - The root Provider registers generated WebMCP read tools with the authenticated
55
+ page session. Write/destructive effects require an explicit page-owned policy.
56
+ Live browser collections remain opt-in per page and must seed from SSR
57
+ `initialData` to avoid a duplicate first request.
55
58
 
56
59
  ## Tests
57
60
 
package/README.md CHANGED
@@ -120,32 +120,27 @@ pnpm smrt schema Item
120
120
  pnpm smrt generate-mcp --no-config --no-readme
121
121
  ```
122
122
 
123
- WebMCP registration is documented as an opt-in, per-page integration using
124
- `collectionDefinitions` from `@happyvertical/smrt-virt-web` and
125
- `registerWebMcpTools()` from `@happyvertical/smrt-web`. Generated model tools
126
- default to read-effect exposure, including custom actions declared as reads.
127
- Write and destructive effects require explicit opt-in, and all custom actions
128
- execute through their generated REST routes.
123
+ The root layout wires the generated `webMcpToolDefinitions` into the Provider,
124
+ so each browser page exposes only read-effect generated model tools by default.
125
+ Write and destructive effects require explicit page-owned opt-in, and all
126
+ custom actions execute through their authenticated generated REST routes. For a
127
+ smaller page-specific surface, pass a filtered `definitions` array or use the
128
+ framework-agnostic `registerWebMcpTools()` API from `@happyvertical/smrt-web`.
129
129
  The CLI's manifest-only `objects` and `schema` commands work in this
130
130
  source-first template. Local-object CRUD execution through the generic CLI
131
131
  additionally requires a compiled JavaScript project entry point.
132
132
 
133
133
  ## 9. Add optional live browser data
134
134
 
135
- `@happyvertical/smrt-web` is intentionally not a base direct dependency. A
136
- consumer adds it only when a page imports the live collection or WebMCP runtime:
137
-
138
- ```bash
139
- pnpm add "@happyvertical/smrt-web@$(node -p "require('./package.json').dependencies['@happyvertical/smrt-core']")"
140
- ```
141
-
142
- Run this inside the generated project. It keeps `smrt-web` on the same release
143
- line as the template's synchronized `smrt-core` dependency.
135
+ `@happyvertical/smrt-web` is included on the synchronized release line because
136
+ the root Provider loads the generated WebMCP definitions. No separate install
137
+ is needed for WebMCP. Live browser collections remain opt-in per page; import
138
+ the collection helpers only on pages that need interactive client data.
144
139
 
145
140
  The generated-project README shows the current hydration pattern:
146
141
  `createSmrtCollection(getCollectionDefinition('items'), { initialData,
147
- basePath: '/api' })` followed by `liveCollection()`. The root layout does not
148
- load the browser engine.
142
+ basePath: '/api' })` followed by `liveCollection()`. The root layout's
143
+ read-only WebMCP registration does not materialize live collections.
149
144
 
150
145
  ## 10. Graduate to smrt-saas-starter
151
146
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happyvertical/smrt-template-sveltekit",
3
- "version": "0.43.4",
3
+ "version": "0.43.5",
4
4
  "description": "Minimal SvelteKit project template with s-m-r-t framework integration",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -29,12 +29,12 @@
29
29
  "directory": "packages/template-sveltekit"
30
30
  },
31
31
  "peerDependencies": {
32
- "@happyvertical/smrt-core": "0.43.4"
32
+ "@happyvertical/smrt-core": "0.43.5"
33
33
  },
34
34
  "devDependencies": {
35
35
  "vitest": "4.1.10",
36
- "@happyvertical/smrt-tenancy": "0.43.4",
37
- "@happyvertical/smrt-users": "0.43.4"
36
+ "@happyvertical/smrt-tenancy": "0.43.5",
37
+ "@happyvertical/smrt-users": "0.43.5"
38
38
  },
39
39
  "publishConfig": {
40
40
  "registry": "https://registry.npmjs.org",
@@ -30,6 +30,8 @@ tools, WebMCP definitions, and agent/developer knowledge artifacts.
30
30
  - Keep object relationship metadata close to `@smrt()`.
31
31
  - Add human-facing routes explicitly; generated REST routes do not create nav
32
32
  pages.
33
- - Add `@happyvertical/smrt-web` only when a dedicated page imports live browser
34
- data or registers WebMCP tools. Seed live collections with SSR `initialData`.
33
+ - The root layout includes `@happyvertical/smrt-web` and registers generated
34
+ WebMCP read tools through Provider when the browser exposes `modelContext`.
35
+ Keep the guard in place for SSR and seed live collections with SSR
36
+ `initialData`.
35
37
  - Do not enable knowledge HTTP routes in production without explicit admin auth.
@@ -249,31 +249,26 @@ Add the jobs package on the same release line as the other
249
249
  `@happyvertical/smrt-*` pins in `package.json`, then reinstall. Missing one of
250
250
  these fails at startup with `ERR_MODULE_NOT_FOUND` naming the package to add.
251
251
 
252
- WebMCP is opt-in per browser surface. First add the browser runtime, then put
253
- registration in a dedicated page that actually exposes tools:
254
-
255
- ```bash
256
- pnpm add "@happyvertical/smrt-web@$(node -p "require('./package.json').dependencies['@happyvertical/smrt-core']")"
257
- ```
258
-
259
- This derives the version from the generated project's synchronized s-m-r-t release
260
- pin, so the optional browser runtime stays on the same release line.
252
+ WebMCP is wired at the root Provider as a read-only, authenticated browser
253
+ surface. The template includes `@happyvertical/smrt-web` on the synchronized
254
+ release line; keep the generated definitions page-owned when you need a
255
+ narrower tool set.
261
256
 
262
257
  ```svelte
263
258
  <script lang="ts">
264
- import { collectionDefinitions } from '@happyvertical/smrt-virt-web';
265
- import { onMount } from 'svelte';
266
-
267
- onMount(() => {
268
- let dispose = () => {};
269
- void import('@happyvertical/smrt-web').then(({ registerWebMcpTools }) => {
270
- dispose = registerWebMcpTools([collectionDefinitions.items], {
271
- basePath: '/api',
272
- });
273
- });
274
- return () => dispose();
275
- });
259
+ import { webMcpToolDefinitions } from '@happyvertical/smrt-virt-web';
260
+ import { Provider } from '@happyvertical/smrt-svelte';
261
+
262
+ const webmcp = $derived(
263
+ typeof document !== 'undefined' && 'modelContext' in document
264
+ ? { definitions: webMcpToolDefinitions, basePath: '/api', effects: ['read'] as const }
265
+ : false,
266
+ );
276
267
  </script>
268
+
269
+ <Provider {webmcp}>
270
+ {@render children()}
271
+ </Provider>
277
272
  ```
278
273
 
279
274
  `registerWebMcpTools()` feature-detects browser support and uses the current
@@ -287,8 +282,9 @@ closed as destructive.
287
282
 
288
283
  ## 9. Add optional live browser data
289
284
 
290
- Use this only on an interactive page. `@happyvertical/smrt-web` must be a direct
291
- dependency because the page imports it; the base starter does not need it.
285
+ Use this only on an interactive page. The template already includes
286
+ `@happyvertical/smrt-web` for the root Provider; no separate install is needed
287
+ for WebMCP. Live browser collections remain opt-in per page.
292
288
 
293
289
  Keep the server load from section 7, then seed the browser collection from its
294
290
  hydrated rows so the first render does not issue a duplicate request:
@@ -25,16 +25,17 @@
25
25
  "svelte-check": "^4.7.2",
26
26
  "typescript": "^6.0.3",
27
27
  "vite": "^8.1.4",
28
- "@happyvertical/smrt-cli": "^0.43.4"
28
+ "@happyvertical/smrt-cli": "^0.43.5"
29
29
  },
30
30
  "dependencies": {
31
- "@happyvertical/smrt-config": "^0.43.4",
32
- "@happyvertical/smrt-core": "^0.43.4",
33
- "@happyvertical/smrt-profiles": "^0.43.4",
34
- "@happyvertical/smrt-svelte": "^0.43.4",
35
- "@happyvertical/smrt-tenancy": "^0.43.4",
36
- "@happyvertical/smrt-ui": "^0.43.4",
37
- "@happyvertical/smrt-users": "^0.43.4",
31
+ "@happyvertical/smrt-config": "^0.43.5",
32
+ "@happyvertical/smrt-core": "^0.43.5",
33
+ "@happyvertical/smrt-profiles": "^0.43.5",
34
+ "@happyvertical/smrt-svelte": "^0.43.5",
35
+ "@happyvertical/smrt-tenancy": "^0.43.5",
36
+ "@happyvertical/smrt-ui": "^0.43.5",
37
+ "@happyvertical/smrt-users": "^0.43.5",
38
+ "@happyvertical/smrt-web": "^0.43.5",
38
39
  "@modelcontextprotocol/server": "^2.0.0"
39
40
  }
40
41
  }
@@ -1,5 +1,6 @@
1
1
  <script lang="ts">
2
2
  import { page } from '$app/state';
3
+ import { webMcpToolDefinitions } from '@happyvertical/smrt-virt-web';
3
4
  import { Provider } from '@happyvertical/smrt-svelte';
4
5
  import {
5
6
  AdminShell,
@@ -18,6 +19,18 @@
18
19
  data.session.activeTenantId ? 'Authorized session tenant' : 'No active tenant',
19
20
  );
20
21
 
22
+ // Keep the optional data-plane runtime out of browsers that do not expose
23
+ // WebMCP. SSR remains safe because the feature check is document-guarded.
24
+ const webmcp = $derived(
25
+ typeof document !== 'undefined' && 'modelContext' in document
26
+ ? {
27
+ definitions: webMcpToolDefinitions,
28
+ basePath: '/api',
29
+ effects: ['read'] as const,
30
+ }
31
+ : false,
32
+ );
33
+
21
34
  // Add application routes here. Generated REST routes live under /api and do
22
35
  // not automatically imply a human-facing page.
23
36
  const nav: ShellNavItem[] = [
@@ -34,7 +47,7 @@
34
47
  ];
35
48
  </script>
36
49
 
37
- <Provider>
50
+ <Provider {webmcp}>
38
51
  <ThemeProvider preset="smrt" colorScheme="system" persist={true}>
39
52
  <AdminShell
40
53
  title="s-m-r-t app"
@@ -0,0 +1,6 @@
1
+ // `smrtPlugin` supplies the runtime virtual module during Vite builds. Keep
2
+ // source-first `svelte-check` useful before that build has emitted its ambient
3
+ // declaration, while preserving the generated shape when the plugin runs.
4
+ declare module '@happyvertical/smrt-virt-web' {
5
+ export const webMcpToolDefinitions: readonly import('@happyvertical/smrt-web').WebMcpToolDefinition[];
6
+ }