@collective-intelligence/extensions-sdk-frontend-react 0.6.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -250,7 +250,7 @@ A connection keeps every field that its template marks secret as a secret. A pac
250
250
 
251
251
  ## Code entrypoints
252
252
 
253
- Code in the template imports CI packages and its own workspaces by package name and exported subpath, for example `@acme/lead/views`, and never by relative path. Each subpath has one folder under `src/` with one `index.ts` and one `exports` entry in `package.json`.
253
+ Code in the template imports CI packages and its own workspaces by package name and exported entry, for example `@packages/features-lead-client`, and never by relative path. A CI SDK splits its code by subpath. A template domain splits its code by part: one package for each runtime.
254
254
 
255
255
  ### SDK subpaths
256
256
 
@@ -268,32 +268,30 @@ The SDKs split by where the code runs. [SDKs](../develop/sdks.md) has the full m
268
268
 
269
269
  Every SDK puts its Promise API at the root and its Effect services, Layers, errors and Schemas at `/effect`. `effect` is a required peer of every SDK, so install it next to the SDK and keep one `effect` version in the app. Optional peers such as Next.js, Express, Drizzle, Better Auth and the AI SDK sit behind their own subpaths, so importing the server SDK root never loads them. In the template, `/next` is imported only inside `apps/web/src/server`, because `/next` loads Next.js and `/effect` does not.
270
270
 
271
- ### Template package subpaths
271
+ ### Template domain parts
272
272
 
273
- Each template package exposes up to six subpaths, and each subpath holds one kind of code:
273
+ Each template domain has up to four parts. A part is one package with one runtime:
274
274
 
275
- | Subpath | Holds | Imported by |
276
- | ---------- | ------------------------------------------------------------------------------------------------ | ----------------------------------------- |
277
- | `domain` | Effect Schema models, resource contracts, schema FQNs, pure rules | Every other subpath and other packages |
278
- | `ci` | CI declarations, written as factories over Organization handles | `@acme/organization` |
279
- | `api` | The package `HttpApi` under `/api/app`, its groups and tagged errors | `server`, `headless`, app API composition |
280
- | `server` | The route Layer of the package `HttpApi` and its services | `apps/web/src/server` only |
281
- | `headless` | Typed client, query options, XState machines, entity bindings, Realtime hooks, simulated sources | `views`, the app |
282
- | `views` | Wired React views on `@acme/ui`, with slots for feature parts | The app |
275
+ | Part | Holds | Imported by |
276
+ | -------- | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------- |
277
+ | `model` | Effect Schema models, resource contracts, pure rules, the domain `HttpApi` under `/api/app`, and the CI names other parts need | the domain's other parts, other domains, the apps |
278
+ | `server` | The route Layer of the domain `HttpApi` and its services | `apps/web/src/server` only |
279
+ | `client` | Typed client, query options, XState machines, entity bindings, Realtime hooks, simulated sources, wired React views | the app |
280
+ | `ci` | CI declarations, written as factories over Identity Domain handles | `apps/extensions` |
283
281
 
284
- Imports point one way. `domain` imports no other subpath, `ci` imports neither `headless` nor `views`, and `headless` and `views` never import `server`. The `ci-solution/subpath-imports` lint rule enforces these rules.
282
+ In one domain, `server`, `client` and `ci` import their own `model` and never each other. Across domains, a part imports only the other domain's `model` part. `turbo boundaries` enforces these rules with the `tier:*`, `runtime:*` and `part:*` tags of each package.
285
283
 
286
- A package exposes only the subpaths it needs. `@acme/lead` has all six, while `@acme/lead-qualification` has only `./ci`, which holds the lead qualifier agent, its Skill, its tool and its Studio widget. The `ci` subpath is where solution code becomes code that CI installs.
284
+ A domain has only the parts it needs. `features/lead` has all four, while `features/lead-qualification` has only `model` and `ci`. Its `ci` part holds the lead qualifier agent, its Skill, its tool and its Studio widget, and its `model` part holds their FQNs. The `ci` part is where solution code becomes code that CI installs.
287
285
 
288
286
  ### Template routes and widgets
289
287
 
290
- The web app has three route files, and each only re-exports handlers from `server/` and the packages:
288
+ The web app has three route files, and each only re-exports handlers from `server/` and the domain parts:
291
289
 
292
- | Route file | Serves |
293
- | ------------------------------------- | ------------------------------------------------------- |
294
- | `app/api/app/[[...path]]/route.ts` | The app's own API, composed from the package `HttpApi`s |
295
- | `app/api/[...path]/route.ts` | The CI BFF: sign-in, Resources, Realtime ticket |
296
- | `app/api/leads/[id]/convert/route.ts` | The fixed convert-lead workflow |
290
+ | Route file | Serves |
291
+ | ------------------------------------- | ------------------------------------------------------ |
292
+ | `app/api/app/[[...path]]/route.ts` | The app's own API, composed from the domain `HttpApi`s |
293
+ | `app/api/[...path]/route.ts` | The CI BFF: sign-in, Resources, Realtime ticket |
294
+ | `app/api/leads/[id]/convert/route.ts` | The fixed convert-lead workflow |
297
295
 
298
296
  Inside CI, a Studio or Dashboard widget enters through a hosted contribution. You write `declareFrontendCatalogContribution({ fqn, host: "studio", load: () => import("./studio") })` and pass it to `declarePackage({ hostedContributions })`. The `load` function stays out of the serialized package manifest, and the loaded module exports `loadFrontendCatalog` for the host.
299
297
 
@@ -8,100 +8,113 @@ What you get from next-effect-app, where each piece of code goes, and how to tak
8
8
 
9
9
  ```bash
10
10
  apps/
11
- web/ # @acme/web Next app: routes, composition, Data Sources, app API and BFF instances
12
- extensions/ # @acme/extensions Extension Package declaration (composition root)
11
+ web/ # @acme/web Next app: routes, composition, Data Sources, app API and BFF instances
12
+ extensions/ # @acme/extensions Extension Package declaration (composes the ci parts)
13
13
  packages/
14
- organization/acme/ # @acme/organization package identity, access, groups, external application
15
- features/intake/ # @acme/intake lead intake: API, store, XState flow, views
16
- features/lead-conversion/ # @acme/lead-conversion convert-lead workflow and browser flow
17
- features/lead-qualification/ # @acme/lead-qualification lead qualifier agent, Skill, tool, Studio widget
18
- entities/lead/ # @acme/lead Lead contract, CI schema, Lead API, Read Port, Realtime, views
19
- entities/opportunity/ # @acme/opportunity Opportunity contract, CI schema, views
20
- modules/identity/ # @acme/identity CI federated auth, CI runtime, principal, login providers
21
- modules/app-api/ # @acme/app-api typed package API client, QueryClient, ApiPrefetch
22
- modules/ui/ # @acme/ui shadcn/ui primitives, AI Elements, theme, workspace-kit
23
- tooling/config/ # @acme/config shared TypeScript base config
14
+ products/acme/identity/{model,ci} # Identity Domain: package identity and VERSION, access, groups, external application, Sales desk
15
+ features/lead/{model,server,client,ci} # Lead contract and CI names, Lead API and Read Port, Realtime and views, CI schema
16
+ features/opportunity/{model,client,ci} # Opportunity contract and CI names, views, CI schema
17
+ features/intake/{model,server,client} # lead intake: schemas and API, store, XState flow and views
18
+ features/lead-conversion/{client,ci} # convert-lead browser flow and Workflow
19
+ features/lead-qualification/{model,ci} # lead qualifier agent, Skill, tool, Studio widget, and their FQNs
20
+ modules/identity-{api,server,client} # principal and Authentication contract, CI runtime, login providers
21
+ modules/app-api, app-api-server # typed domain API client, QueryClient, simulated network; ApiPrefetch
22
+ ui/design-system/ # shadcn/ui primitives, AI Elements, theme, workspace-kit
23
+ tooling/config/ # shared TypeScript base config and the Layout Guard
24
24
  ```
25
25
 
26
- Intake is a form with an XState flow and an app API that keeps its data in an in-memory store. Lead conversion is a Fixed workflow started by a single-action task. Lead qualification is an agent with a Skill, a tool and a Studio widget. The repository has no docs wiki, no infra folder and no generated client code, because the browser derives each typed client from its package `HttpApi` at runtime. It also ships an agent harness: an `AGENTS.md` per scope, and `.agents/` with skills, rules and lint scripts.
26
+ Intake is a form with an XState flow and an app API that keeps its data in an in-memory store. Lead conversion is a Fixed workflow started by a single-action task. Lead qualification is an agent with a Skill, a tool and a Studio widget. The repository has no docs wiki, no infra folder and no generated client code, because the browser derives each typed client from its domain `HttpApi` at runtime. It also ships an agent harness: an `AGENTS.md` per scope, and `.agents/` with skills, rules and lint scripts.
27
27
 
28
- ## Tiers and the import rule
28
+ ## Domains, parts and the import rules
29
29
 
30
- Every package lives at `packages/<tier>/<name>`, keeps a flat name (`@acme/<name>`) and has exactly one `tier:*` tag in its own `turbo.json`. The six tiers, from top to bottom, are `app` (the composition roots), `organization` (package identity, access, groups, external application and deploy order), `features` (one user-visible capability each), `entities` (one business entity each), `modules` (business-agnostic machinery) and `tooling` (the shared tsconfig base).
30
+ The template groups its code by domain. One domain is one folder, and each runtime of the domain is its own package, a part. The folder directly below `packages/` is the kind:
31
+
32
+ | Kind | Holds |
33
+ | ------------------------------------ | ---------------------------------------------------------- |
34
+ | `features/<domain>/<part>` | a domain that names no product, such as `lead` or `intake` |
35
+ | `products/<product>/<domain>/<part>` | a domain of one product; it may name its product |
36
+ | `ui/<name>` | the design system and page blocks, with no product terms |
37
+ | `modules/<name>` | business-agnostic machinery with one runtime |
38
+ | `tooling/<name>` | TypeScript, lint, build and test configuration |
39
+
40
+ A domain has only the parts it needs, and each part has exactly one runtime:
41
+
42
+ | Part | Runtime | Holds |
43
+ | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------ |
44
+ | `model` | neutral | Effect Schema models, resource contracts, pure rules, the domain `HttpApi` under `/api/app`, and the CI names other parts need |
45
+ | `server` | server | the route Layer of the domain `HttpApi` and its services; only `apps/web/src/server` imports it |
46
+ | `client` | client | typed client, query options, XState machines, entity bindings, Realtime topics and hooks, simulated sources, wired React views |
47
+ | `ci` | ci | CI declarations (extensions SDK) as factories over Identity Domain handles |
48
+
49
+ A package name is `@packages/` plus its path below `packages/`, with `-` in place of `/`. For example, `packages/features/lead/client` is `@packages/features-lead-client`. The apps keep their own names. Every internal dependency uses `workspace:*`. A part exports `.`, and a `client` part adds `./headless` only when a consumer needs state without components.
31
50
 
32
51
  ```mermaid
33
52
  flowchart TD
34
53
  web["apps/web"]
35
54
  ext["apps/extensions"]
36
- org["organization<br/>@acme/organization"]
37
- subgraph features["features"]
38
- f1["intake"]
39
- f2["lead-conversion"]
40
- f3["lead-qualification"]
55
+ subgraph identity["products/acme/identity"]
56
+ im["model"]
57
+ ic["ci"]
41
58
  end
42
- subgraph entities["entities"]
43
- e1["lead"]
44
- e2["opportunity"]
59
+ subgraph lead["features/lead"]
60
+ lm["model"]
61
+ ls["server"]
62
+ lc["client"]
63
+ lci["ci"]
45
64
  end
46
- subgraph modules["modules"]
47
- m1["identity"]
48
- m2["app-api"]
49
- m3["ui"]
65
+ subgraph conv["features/lead-conversion"]
66
+ cc["client"]
67
+ cci["ci"]
50
68
  end
51
- tooling["tooling<br/>config"]
52
- web --> org
53
- ext -->|"lists CI declarations in deploy order"| org
54
- ext -->|"lists each ./ci"| features
55
- org -->|"grants package capabilities"| features
56
- features --> entities
57
- entities --> modules
58
- modules --> tooling
59
- f1 -.-|"never imports"| f2
60
- e1 -.-|"never imports"| e2
69
+ modules["modules, ui, tooling"]
70
+ web -->|"composes server and client parts"| ls
71
+ web --> lc
72
+ web --> cc
73
+ ext -->|"lists each ci part in deploy order"| lci
74
+ ext --> cci
75
+ ext --> ic
76
+ ic -->|"grants by the names in model parts"| lm
77
+ ls --> lm
78
+ lc --> lm
79
+ lci --> lm
80
+ cc -->|"another domain's model only"| lm
81
+ lc --> modules
82
+ lc -.-|"never imports"| cc
61
83
  ```
62
84
 
63
- Imports point down the tiers and may skip a tier. Inside one tier, only modules and tooling packages import each other. A feature never imports another feature and an entity never imports another entity. When two of them must work together, a page in `apps/web` connects them.
85
+ - In one domain, `server`, `client` and `ci` import their own `model`. They never import each other.
86
+ - Across domains, a part imports only the other domain's `model` part. The `server`, `client` and `ci` parts of different domains meet only in an app: `apps/web` composes the views, and `apps/extensions` composes the `ci` parts.
87
+ - `features`, `ui` and `modules` never import `products`. A product never imports another product.
88
+ - `ui` imports only `ui` and `tooling`. `modules` imports only `modules` and `tooling`.
64
89
 
65
- The arrows are real configuration. The root `turbo.json` lists, for each tag, the tags it may depend on, and `bunx turbo boundaries` fails the build on a wrong import:
90
+ The rules are real configuration. Each workspace `turbo.json` has the Boundary Tags of its place: one `tier:*` tag, one `runtime:*` tag (apps have none), and one `part:*` tag for a part. The root `turbo.json` holds one rule for each tag, and `bunx turbo boundaries` fails the build on a wrong import:
66
91
 
67
92
  ```json
68
- "tier:features": { "dependencies": { "allow": ["tier:entities", "tier:modules", "tier:tooling"] } },
69
- "tier:entities": { "dependencies": { "allow": ["tier:modules", "tier:tooling"] } },
70
- "tier:modules": { "dependencies": { "allow": ["tier:modules", "tier:tooling"] } }
93
+ "tier:features": { "dependencies": { "allow": ["tier:features", "tier:ui", "tier:modules", "tier:tooling"] } },
94
+ "runtime:client": { "dependencies": { "deny": ["runtime:server", "runtime:ci"] } },
95
+ "part:client": { "dependencies": { "deny": ["part:server", "part:client", "part:ci"] } }
71
96
  ```
72
97
 
73
- Workspaces import each other by package name and exported subpath, such as `@acme/lead/views`, and never by relative path.
98
+ The full table is `BOUNDARY_TAGS` from `@collective-intelligence/lint/layout`. The `part:*` rules deny every `server`, `client` and `ci` part, so a part reaches only `model` parts. An app has no `part:*` tag, so the parts of different domains meet there.
74
99
 
75
- ## Package subpaths
100
+ Workspaces import each other by package name and exported entry, such as `@packages/features-lead-client`, and never by relative path.
76
101
 
77
- A feature or entity package exposes only the subpaths it needs. Each subpath is a folder under `src/` with one `index.ts` and one `exports` entry in `package.json`.
102
+ The template has these domains:
78
103
 
79
- | Subpath | Holds | Imported by |
80
- | ---------- | ----------------------------------------------------------------------------------------------------------- | --------------------------------------------- |
81
- | `domain` | Effect Schema models, resource contracts, schema FQNs, pure rules | every other subpath and other packages |
82
- | `ci` | CI declarations (extensions SDK) as factories over organization handles | `apps/extensions`, `@acme/organization` |
83
- | `api` | the package `HttpApi` under `/api/app`, its groups and tagged errors | `server`, `headless`, the app API composition |
84
- | `server` | the route Layer of the package `HttpApi` and its services | `apps/web/src/server` only |
85
- | `headless` | typed client, query options, XState machines, entity bindings, Realtime topics and hooks, simulated sources | `views` and the app |
86
- | `views` | wired React views on `@acme/ui`; feature parts enter through slots | the app |
104
+ | Domain | Parts |
105
+ | ----------------------------- | --------------------------------- |
106
+ | `features/lead` | `model`, `server`, `client`, `ci` |
107
+ | `features/opportunity` | `model`, `client`, `ci` |
108
+ | `features/intake` | `model`, `server`, `client` |
109
+ | `features/lead-conversion` | `client`, `ci` |
110
+ | `features/lead-qualification` | `model`, `ci` |
111
+ | `products/acme/identity` | `model`, `ci` |
87
112
 
88
- Inside a package the subpaths also have a direction. `domain` imports no other subpath, `ci` imports neither `headless` nor `views`, and `headless` and `views` never import `server`. That keeps server code out of the browser bundle and keeps CI declarations free of React.
113
+ `features/lead-qualification` adds an agent, a Skill, a tool and a Studio widget, and all of that is CI-side behavior. Its `model` holds only the FQNs, and its `ci` part holds the declarations. That shows that you can ship an AI capability without writing any web code.
89
114
 
90
- Each template package exposes a different set:
115
+ ## Domains take their audience as a parameter
91
116
 
92
- | Package | Subpaths |
93
- | -------------------------- | ------------------------------------- |
94
- | `@acme/lead` | `domain ci api server headless views` |
95
- | `@acme/opportunity` | `domain ci headless views` |
96
- | `@acme/intake` | `domain api server headless views` |
97
- | `@acme/lead-conversion` | `ci headless views` |
98
- | `@acme/lead-qualification` | `ci` |
99
-
100
- `@acme/lead-qualification` adds an agent, a Skill, a tool and a Studio widget, and all of that is CI-side behavior. Its single `./ci` subpath shows that you can ship an AI capability without writing any web code.
101
-
102
- ## Features take their audience as a parameter
103
-
104
- A feature package must not import `@acme/organization`, because organization sits above it in the tiers. A feature that offers something to a group of users therefore takes that `audience`, and the application handle, as parameters. The organization package owns the groups, the application and the profiles; each entity package declares its own capabilities and Knowledge Data Policies, and the profiles grant them by the FQN constants of `@acme/lead/ci` and `@acme/opportunity/ci`. `apps/extensions/src/index.ts` passes the organization handles in and lists every component in deploy order, where each component follows the components it references:
117
+ `products/acme/identity` is the Identity Domain of the product `acme`. Its `model` part holds the package identity and `VERSION`. Its `ci` part holds the groups, the application, the Access Profiles, their grants and the Max Privileges. A `features` domain never imports a product, so a `ci` part that offers something to a group of users takes that `audience`, and the application handle, as parameters. Each domain declares its own capabilities and Knowledge Data Policies in its `ci` part. The profiles grant them by the FQN constants of `@packages/features-lead-model` and `@packages/features-opportunity-model`. `apps/extensions/src/index.ts` passes the Identity Domain handles in and lists every component in deploy order, where each component follows the components it references:
105
118
 
106
119
  ```ts
107
120
  export default declarePackage({
@@ -109,7 +122,7 @@ export default declarePackage({
109
122
  crmDomain,
110
123
  ...leadComponents({ domain: crmDomain, version: VERSION }),
111
124
  ...opportunityComponents({ domain: crmDomain, version: VERSION }),
112
- ...organizationComponents,
125
+ ...identityComponents,
113
126
  ...convertLeadComponents({
114
127
  application: acmeApplication,
115
128
  version: VERSION
@@ -126,21 +139,21 @@ export default declarePackage({
126
139
  })
127
140
  ```
128
141
 
129
- `organizationComponents` holds the Sales Group, the application, the profiles, their grants and the Max Privileges. The Studio contribution is the one declaration in `apps/extensions`: `ci package build` resolves its relative `load` import against that file.
142
+ `identityComponents` holds the Sales Group, the application, the profiles, their grants and the Max Privileges. The Studio contribution is the one declaration in `apps/extensions`: `ci package build` resolves its relative `load` import against that file.
130
143
 
131
144
  [Extensions](../develop/extensions.md) describes each kind of declaration, and [Access](../platform/access.md) explains the Access Profiles and Access Grants in that list.
132
145
 
133
146
  ## The web app layers
134
147
 
135
- Entity and feature code lives in packages. The web app keeps only routes, Composition, the sign-in gate, Data Sources and server instances, arranged in a fixed set of layers where each layer imports only the layers below it:
148
+ Domain code lives in the domain parts. The web app keeps only routes, Composition, the sign-in gate, Data Sources and server instances, arranged in a fixed set of layers where each layer imports only the layers below it:
136
149
 
137
- | Layer in `apps/web/src` | Holds |
138
- | ----------------------- | --------------------------------------------------------------------------------------------------------------------- |
139
- | `app/` | route files only; each re-exports a Composition export, and `app/api/**` forwards to `server/<domain>/server` |
140
- | `composition/` | `providers/` (global providers, Realtime providers) and `routing/` (access, shells, pages) |
141
- | `features/` | app-local capabilities: their Data Sources (`remote/server.ts`) and `page-link/` |
142
- | `entities/` | app-local entity machinery that several features need (the CI session), Data Sources of entity packages, `page-link/` |
143
- | `server/` | beside the layers: one folder per domain, where `server.ts` (`server-only`) holds the process instance |
150
+ | Layer in `apps/web/src` | Holds |
151
+ | ----------------------- | ------------------------------------------------------------------------------------------------------------------ |
152
+ | `app/` | route files only; each re-exports a Composition export, and `app/api/**` forwards to `server/<domain>/server` |
153
+ | `composition/` | `providers/` (global providers, Realtime providers) and `routing/` (access, shells, pages) |
154
+ | `features/` | app-local capabilities: their Data Sources (`remote/server.ts`) and `page-link/` |
155
+ | `entities/` | app-local entity machinery that several features need (the CI session), Data Sources of domain parts, `page-link/` |
156
+ | `server/` | beside the layers: one folder per domain, where `server.ts` (`server-only`) holds the process instance |
144
157
 
145
158
  Only Composition imports a Data Source, and only Data Sources and `app/api/**` import a `server/<domain>/server.ts`. Peers still meet without importing each other: the CRM page template passes `ConvertLead` into the `selectionActions` slot of `LeadWorkspace` and `LeadAttachment` into its `editorActions` slot. Each page's owner gives its `{ label, path }` in `page-link/`, and shells and links read it, so no route path is written twice.
146
159
 
@@ -148,7 +161,7 @@ One Next app serves two server surfaces:
148
161
 
149
162
  | Path | Handler | What it is |
150
163
  | ------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------ |
151
- | `/api/app/*` | `server/app-api/server` | the app API: the packages' Effect `HttpApi`s merged, OpenAPI at `/api/app/openapi.json`, Scalar docs at `/api/app/docs` |
164
+ | `/api/app/*` | `server/app-api/server` | the app API: the domains' Effect `HttpApi`s merged , OpenAPI at `/api/app/openapi.json`, Scalar docs at `/api/app/docs` |
152
165
  | `/api/*` | `server/ci/server` | the CI SDK BFF: sign-in with a sealed cookie, Lead and Opportunity resource proxy, Realtime ticket and revalidate routes |
153
166
  | `/api/leads/[id]/convert` | `server/ci/server` | the Fixed convert-lead workflow route |
154
167
 
@@ -157,7 +170,7 @@ The BFF holds the CI session in a sealed cookie and proxies resource calls, so t
157
170
  ## Start a new demo
158
171
 
159
172
  1. Generate a repository with **Use this template** on the template repository. In the new repository, delete the README "Contributing" section and `.github/workflows/close-pull-requests.yml`, which only matter in the template repository itself.
160
- 2. Rename the template for the customer. Replace the `@acme/` package scopes and the `acme.app.` FQNs, replace `https://acme.localhost` in `packages/organization/acme/src/application.ts` and `.env.example`, and replace the theme tokens and the sidebar brand in `apps/web/src/composition/routing/shells/workspace/app-sidebar.tsx`. Theme tokens live once, in `packages/modules/ui/src/styles/globals.css`.
173
+ 2. Rename the template for the customer. Replace the `@acme/` app names, the product folder `packages/products/acme` with its package names `@packages/products-acme-*`, and the `acme.app.` FQNs. Replace `https://acme.localhost` in `packages/products/acme/identity/ci/src/application.ts` and `.env.example`, and replace the theme tokens and the sidebar brand in `apps/web/src/composition/routing/shells/workspace/app-sidebar.tsx`. Theme tokens live once, in `packages/ui/design-system/src/styles/globals.css`.
161
174
  3. Run it locally. The Overview and Lead intake pages work with no configuration, because the intake API keeps requests in memory:
162
175
 
163
176
  ```bash
@@ -226,22 +239,22 @@ The BFF holds the CI session in a sealed cookie and proxies resource calls, so t
226
239
 
227
240
  ## What to change and what to keep
228
241
 
229
- A new demo changes the organization package, the entities, the features, the theme and the origins. It keeps `modules/identity`, `modules/app-api`, the BFF and server wiring, the tier tags, the lint configuration and the harness files, because they hold no business logic. A new environment variable goes into `apps/web/.env.example`, `packages/modules/identity/src/server/env.ts`, `turbo.json` `globalEnv` and the README tenant section together.
242
+ A new demo changes the Identity Domain, the `features` domains, the theme and the origins. It keeps the `modules/identity-*` and `modules/app-api*` packages, the BFF and server wiring, the Boundary Tags, the Layout Guard, the lint configuration and the harness files, because they hold no business logic. A new environment variable goes into `apps/web/.env.example`, `packages/modules/identity-server/src/env.ts`, `turbo.json` `globalEnv` and the README tenant section together.
230
243
 
231
244
  ## Checks that keep the structure honest
232
245
 
246
+ Three checks keep the layout. `turbo boundaries` checks every import against the Boundary Tags. The Layout Guard, the Bun test `packages/tooling/config/src/workspace-layout.test.ts`, checks what the tags cannot express: the root `workspaces` globs, package names, each `turbo.json`, `workspace:*` ranges and product isolation. The `ci-solution/workspace-layout` lint rule reports a package that sits outside the accepted places. All three read one layout definition, `@collective-intelligence/lint/layout`.
247
+
233
248
  `@collective-intelligence/lint` is one Oxlint plugin named `ci-solution`. Extending `recommended` turns every rule on as an error:
234
249
 
235
- | Rule | Checks |
236
- | -------------------------------- | ---------------------------------------------------------------------------------- |
237
- | `ci-solution/package-entrypoint` | an import of another package targets an entrypoint in its `package.json` `exports` |
238
- | `ci-solution/subpath-imports` | imports between subpath folders follow the allowed direction |
239
- | `ci-solution/subpath-entrypoint` | an import of another subpath folder targets its index file |
240
- | `ci-solution/subpath-index` | every subpath folder has `index.ts` or `index.tsx` |
241
- | `ci-solution/effect-subpath` | SDK Effect APIs come from the SDK `/effect` subpath |
242
- | `ci-solution/no-run-in-view` | a view module calls no `fetch` and runs no Effect |
243
- | `ci-solution/effect-actors` | XState side-effect actors are `fromEffect` actors |
244
- | `ci-solution/effect-writes` | no module uses TanStack Query `useMutation`; writes run in `fromEffect` actors |
250
+ | Rule | Checks |
251
+ | -------------------------------- | ---------------------------------------------------------------------------------------------- |
252
+ | `ci-solution/package-entrypoint` | an import of another package targets an entrypoint in its `package.json` `exports` |
253
+ | `ci-solution/workspace-layout` | each workspace sits at `apps/<name>`, a domain part, or `packages/{ui,modules,tooling}/<name>` |
254
+ | `ci-solution/effect-subpath` | SDK Effect APIs come from the SDK `/effect` subpath |
255
+ | `ci-solution/no-run-in-view` | a view module calls no `fetch` and runs no Effect |
256
+ | `ci-solution/effect-actors` | XState side-effect actors are `fromEffect` actors |
257
+ | `ci-solution/effect-writes` | no module uses TanStack Query `useMutation`; writes run in `fromEffect` actors |
245
258
 
246
259
  Each package has an `oxlint.local.ts` that extends the preset:
247
260
 
@@ -264,14 +277,14 @@ The web app also runs a `frontend-layers` lint for layer order, domain entrypoin
264
277
 
265
278
  ```bash
266
279
  bun run check-types
267
- bun run test
280
+ bun run test # includes the Layout Guard
268
281
  bunx turbo boundaries
269
282
  bun run lint
270
283
  bun run format:check
271
284
  bun run build
272
285
  ```
273
286
 
274
- When you change the Lead cache, a Lead write or Lead Realtime, also run `bun run check:models` in `packages/entities/lead`. [State machines](state-machines.md) explains what that command checks.
287
+ When you change the Lead cache, a Lead write or Lead Realtime, also run `bun run check:models` in `packages/features/lead/client`. [State machines](state-machines.md) explains what that command checks.
275
288
 
276
289
  ## Related pages
277
290
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  How next-effect-app models UI flows as XState machines with Effect actors, keeps server data in the QueryCache, resends uncertain writes safely, and checks hard flows with Models.
4
4
 
5
- In `next-effect-app`, a UI flow that carries business logic is an XState machine in the `headless/` folder of its package, at `headless/<flow>-machine.ts`. Flows that belong only to the web app live at `apps/web/src/{features,entities}/<domain>/<flow>-machine.ts`. The machine decides where the flow is: editing, reviewing, submitting, failed. Every side effect is an Effect program that the machine runs as an actor, and TanStack Query owns the remote data that those programs read and write.
5
+ In `next-effect-app`, a UI flow that carries business logic is an XState machine in the `src/headless/` folder of its domain's `client` part, at `src/headless/<flow>-machine.ts`. Flows that belong only to the web app live at `apps/web/src/{features,entities}/<domain>/<flow>-machine.ts`. The machine decides where the flow is: editing, reviewing, submitting, failed. Every side effect is an Effect program that the machine runs as an actor, and TanStack Query owns the remote data that those programs read and write.
6
6
 
7
7
  The machine context holds flow state only and never an API response. Two views that show the same record therefore read one cache entry, and no machine keeps a copy that can go stale. Server Components never run machines or Effects; they await a Promise boundary, and machines exist only in client code.
8
8
 
@@ -72,7 +72,7 @@ submitting: {
72
72
 
73
73
  Leaving the invoking state interrupts the Effect fiber. The machine has no UI of its own: `submitted` is a typed action, and the view provides the toast with `machine.provide({ actions })`. The view runs `useMachine(intakeMachine.provide(...), { input: { runtime } })` and renders by `snapshot.matches("editing")`, `matches("submitting")` and `matches("done")`.
74
74
 
75
- The same `provide` call swaps the data source for a demo without a backend. A simulated source lives in `headless/simulated-*.ts`, built with `simulate("<pace>", effect)` from `@acme/app-api`, and only Composition or a test selects it. Tests use the same mechanism. A test drives the machine on a `ManagedRuntime` of the SDK `makeTestQueryCache` layer, never a hand-made `QueryCache` double, and asserts on cache entries or recorded calls:
75
+ The same `provide` call swaps the data source for a demo without a backend. A simulated source lives in `headless/simulated-*.ts`, built with `simulate("<pace>", effect)` from `@packages/modules-app-api`, and only Composition or a test selects it. Tests use the same mechanism. A test drives the machine on a `ManagedRuntime` of the SDK `makeTestQueryCache` layer, never a hand-made `QueryCache` double, and asserts on cache entries or recorded calls:
76
76
 
77
77
  ```ts
78
78
  const cache = makeTestQueryCache({ seed: [[intakeRequestsQuery.queryKey, []]] })
@@ -160,7 +160,7 @@ stateDiagram-v2
160
160
  done --> running: RUN with a new file
161
161
  ```
162
162
 
163
- The steps inside `running` are steps of the Effect program, and the machine itself sees one `running` state. A resubmit skips the upload and sends only the final write. The size and type checks use `leadAttachmentAccepts` and `leadAttachmentMaxBytes` (5 MiB) from `@acme/lead/domain`. The CI schema declares the same values on the File field, so CI refuses a larger upload too, while a file that fails the local check sends nothing.
163
+ The steps inside `running` are steps of the Effect program, and the machine itself sees one `running` state. A resubmit skips the upload and sends only the final write. The size and type checks use `leadAttachmentAccepts` and `leadAttachmentMaxBytes` (5 MiB) from `@packages/features-lead-model`. The CI schema declares the same values on the File field, so CI refuses a larger upload too, while a file that fails the local check sends nothing.
164
164
 
165
165
  The write that might need a resend is a value the failure carries:
166
166
 
@@ -224,7 +224,7 @@ A Model is a `*.proof.ts` TypeScript module that states the state, actions and i
224
224
  | `/** @constraint */` | a bound, so the search ends |
225
225
  | `ghost` prefix on a `let` | records what a consumer saw, only to state a guarantee |
226
226
 
227
- The Lead Realtime Model in `packages/entities/lead` is trimmed here. The full file also has `writeConfirm`, `otherWrite`, `realtimeChange` and `neverBehindConfirmed`:
227
+ The Lead Realtime Model in `packages/features/lead/client/src/headless/lead-realtime.proof.ts` is trimmed here. The full file also has `writeConfirm`, `otherWrite`, `realtimeChange` and `neverBehindConfirmed`:
228
228
 
229
229
  ```ts
230
230
  let server: Revision = 0
@@ -260,7 +260,7 @@ export const isRefetchDue = () => refetchDue && !isFresh()
260
260
  The checker visits 22 states and proves two things. A Realtime refetch never hides the tab's pending optimistic write (`pendingWriteShown`, `neverBehindConfirmed`), and after a Realtime change the views eventually reach the stored revision (`@leadsTo isFresh`). The package runs it with one script:
261
261
 
262
262
  ```bash
263
- cd packages/entities/lead
263
+ cd packages/features/lead/client
264
264
  bun run check:models
265
265
  ```
266
266
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@collective-intelligence/extensions-sdk-frontend-react",
3
- "version": "0.6.0",
3
+ "version": "0.7.1",
4
4
  "description": "Public hosted React contribution contracts for Collective Intelligence extensions.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -80,11 +80,12 @@
80
80
  "type-check": "bun check --no-script -p tsconfig.json && bun check --no-script -p tsconfig.type-tests.json"
81
81
  },
82
82
  "dependencies": {
83
- "@collective-intelligence/extensions-sdk": "0.6.0",
84
- "@collective-intelligence/extensions-sdk-frontend": "0.6.0"
83
+ "@collective-intelligence/effect-xstate": "0.7.1",
84
+ "@collective-intelligence/extensions-sdk": "0.7.1",
85
+ "@collective-intelligence/extensions-sdk-frontend": "0.7.1"
85
86
  },
86
87
  "peerDependencies": {
87
- "@collective-intelligence/ui-react": "0.6.0",
88
+ "@collective-intelligence/ui-react": "0.7.1",
88
89
  "@tanstack/react-query": ">=5 <6",
89
90
  "@xyflow/react": ">=12 <13",
90
91
  "effect": "^4.1.0",
@@ -101,7 +102,7 @@
101
102
  "access": "public"
102
103
  },
103
104
  "devDependencies": {
104
- "@collective-intelligence/ui-react": "0.6.0",
105
+ "@collective-intelligence/ui-react": "0.7.1",
105
106
  "@effect/eslint-plugin": "0.3.2",
106
107
  "@effect/vitest": "4.1.4",
107
108
  "@hey-api/openapi-ts": "^0.96.0",
@@ -129,5 +130,5 @@
129
130
  "vitest": "5.0.2",
130
131
  "xstate": "5.33.3"
131
132
  },
132
- "gitHead": "94535cc59ece904d4a9374a368edb09222688bb6"
133
+ "gitHead": "822e4e2a259aa39e865d40504f6ac1e85d9c182a"
133
134
  }
@@ -1,14 +0,0 @@
1
- import type * as Effect from "effect/Effect";
2
- import type * as ManagedRuntime from "effect/ManagedRuntime";
3
- import type { PromiseActorLogic } from "xstate";
4
- /** What runs an effect for an actor: a `ManagedRuntime` that provides `R`. */
5
- export type EffectRunner<R> = Pick<ManagedRuntime.ManagedRuntime<R, never>, "runPromise">;
6
- /**
7
- * XState actor logic that runs the effect of `run` on the runtime of the actor
8
- * input. The actor's output is the effect's value; a failure or a defect fails
9
- * the actor. A stop of the actor interrupts the fiber, so its run settles.
10
- * After the stop, no result of that run gets to the actor.
11
- */
12
- export declare const fromEffect: <A, E, R, I extends {
13
- readonly runtime: EffectRunner<R>;
14
- }>(run: (input: I) => Effect.Effect<A, E, R>) => PromiseActorLogic<A, I>;