@elevasis/sdk 1.20.2 → 1.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/dist/cli.cjs +4220 -1583
  2. package/dist/index.d.ts +1035 -481
  3. package/dist/index.js +7381 -4187
  4. package/dist/node/index.d.ts +1 -3
  5. package/dist/node/index.js +40 -49
  6. package/dist/test-utils/index.d.ts +699 -123
  7. package/dist/test-utils/index.js +3826 -630
  8. package/dist/worker/index.js +3616 -442
  9. package/package.json +3 -3
  10. package/reference/_navigation.md +9 -7
  11. package/reference/_reference-manifest.json +1 -1
  12. package/reference/claude-config/hooks/post-edit-validate.mjs +98 -98
  13. package/reference/claude-config/hooks/scaffold-registry-reminder.mjs +188 -188
  14. package/reference/claude-config/hooks/tool-failure-recovery.mjs +73 -73
  15. package/reference/claude-config/registries/graph-skills.json +4 -4
  16. package/reference/claude-config/registries/knowledge-flags.json +0 -2
  17. package/reference/claude-config/rules/active-change-index.md +80 -80
  18. package/reference/claude-config/rules/agent-start-here.md +277 -273
  19. package/reference/claude-config/rules/deployment.md +57 -57
  20. package/reference/claude-config/rules/error-handling.md +56 -56
  21. package/reference/claude-config/rules/execution.md +40 -40
  22. package/reference/claude-config/rules/frontend.md +4 -4
  23. package/reference/claude-config/rules/observability.md +31 -31
  24. package/reference/claude-config/rules/operations.md +29 -17
  25. package/reference/claude-config/rules/organization-model.md +108 -40
  26. package/reference/claude-config/rules/organization-os.md +115 -113
  27. package/reference/claude-config/rules/package-taxonomy.md +33 -33
  28. package/reference/claude-config/rules/platform.md +42 -42
  29. package/reference/claude-config/rules/shared-types.md +49 -46
  30. package/reference/claude-config/rules/task-tracking.md +47 -47
  31. package/reference/claude-config/rules/ui.md +200 -200
  32. package/reference/claude-config/rules/vibe.md +235 -231
  33. package/reference/claude-config/scripts/statusline-command.js +18 -18
  34. package/reference/claude-config/settings.json +34 -34
  35. package/reference/claude-config/skills/deploy/{SKILL.md → skill.md} +156 -156
  36. package/reference/claude-config/skills/dsp/SKILL.md +66 -66
  37. package/reference/claude-config/skills/elevasis/SKILL.md +235 -235
  38. package/reference/claude-config/skills/explore/SKILL.md +6 -6
  39. package/reference/claude-config/skills/git-sync/SKILL.md +126 -126
  40. package/reference/claude-config/skills/knowledge/SKILL.md +330 -271
  41. package/reference/claude-config/skills/knowledge/operations/codify-level-a.md +100 -100
  42. package/reference/claude-config/skills/knowledge/operations/codify-level-b.md +159 -158
  43. package/reference/claude-config/skills/knowledge/operations/customers.md +109 -109
  44. package/reference/claude-config/skills/knowledge/operations/features.md +76 -113
  45. package/reference/claude-config/skills/knowledge/operations/goals.md +118 -118
  46. package/reference/claude-config/skills/knowledge/operations/identity.md +93 -93
  47. package/reference/claude-config/skills/knowledge/operations/labels.md +94 -89
  48. package/reference/claude-config/skills/knowledge/operations/offerings.md +109 -109
  49. package/reference/claude-config/skills/knowledge/operations/roles.md +99 -99
  50. package/reference/claude-config/skills/knowledge/operations/techStack.md +30 -30
  51. package/reference/claude-config/skills/project/SKILL.md +1088 -1088
  52. package/reference/claude-config/skills/run-ui/SKILL.md +73 -73
  53. package/reference/claude-config/skills/save/SKILL.md +3 -3
  54. package/reference/claude-config/skills/setup/SKILL.md +275 -275
  55. package/reference/claude-config/skills/status/SKILL.md +59 -59
  56. package/reference/claude-config/skills/submit-request/SKILL.md +180 -180
  57. package/reference/claude-config/skills/sync/SKILL.md +47 -47
  58. package/reference/claude-config/skills/tutorial/SKILL.md +259 -259
  59. package/reference/claude-config/skills/tutorial/progress-template.md +74 -74
  60. package/reference/claude-config/skills/tutorial/technical.md +1303 -1306
  61. package/reference/claude-config/skills/tutorial/vibe-coder.md +890 -890
  62. package/reference/claude-config/sync-notes/2026-04-22-git-sync-and-sync-notes.md +27 -27
  63. package/reference/claude-config/sync-notes/2026-04-22-lead-gen-deliverability-removal.md +30 -30
  64. package/reference/claude-config/sync-notes/2026-04-24-test-utils-and-template-tests.md +73 -73
  65. package/reference/claude-config/sync-notes/2026-04-24-ui-consolidation-and-sdk-cli-train.md +86 -86
  66. package/reference/claude-config/sync-notes/2026-04-25-auth-role-system-and-settings-roles.md +55 -55
  67. package/reference/claude-config/sync-notes/2026-04-27-crm-hitl-action-layer-cutover.md +97 -97
  68. package/reference/claude-config/sync-notes/2026-04-27-lead-gen-substrate-train.md +112 -112
  69. package/reference/claude-config/sync-notes/2026-04-29-crm-state-and-lead-gen-processing-status.md +93 -93
  70. package/reference/claude-config/sync-notes/2026-05-02-crm-ownership-next-action.md +58 -58
  71. package/reference/claude-config/sync-notes/2026-05-02-template-hardcode-workos-config.md +56 -56
  72. package/reference/claude-config/sync-notes/2026-05-04-elevasis-workspace.md +71 -71
  73. package/reference/claude-config/sync-notes/2026-05-04-knowledge-bundle.md +83 -83
  74. package/reference/claude-config/sync-notes/2026-05-04-template-skills-run-ui-and-tutorial.md +59 -59
  75. package/reference/claude-config/sync-notes/2026-05-05-list-builder.md +42 -42
  76. package/reference/claude-config/sync-notes/2026-05-06-crm-spine.md +60 -60
  77. package/reference/claude-config/sync-notes/2026-05-06-sdk-changes-release-train.md +37 -37
  78. package/reference/claude-config/sync-notes/2026-05-07-sdk-changes-release-train.md +34 -34
  79. package/reference/claude-config/sync-notes/2026-05-08-resource-governance-scaffold-guidance.md +38 -38
  80. package/reference/claude-config/sync-notes/2026-05-09-clients-domain.md +32 -32
  81. package/reference/claude-config/sync-notes/2026-05-09-command-system.md +33 -33
  82. package/reference/claude-config/sync-notes/2026-05-09-resource-governance-and-misc.md +69 -69
  83. package/reference/claude-config/sync-notes/2026-05-12-sdk-ready-release-train.md +30 -0
  84. package/reference/claude-config/sync-notes/2026-05-14-organization-model-ontology-refactor.md +42 -0
  85. package/reference/claude-config/sync-notes/README.md +43 -43
  86. package/reference/cli.mdx +808 -668
  87. package/reference/concepts.mdx +146 -146
  88. package/reference/deployment/api.mdx +297 -297
  89. package/reference/deployment/command-center.mdx +209 -209
  90. package/reference/deployment/index.mdx +195 -195
  91. package/reference/deployment/provided-features.mdx +107 -93
  92. package/reference/deployment/ui-execution.mdx +250 -250
  93. package/reference/examples/organization-model.ts +147 -84
  94. package/reference/framework/agent.mdx +156 -156
  95. package/reference/framework/index.mdx +195 -195
  96. package/reference/framework/interaction-guidance.mdx +182 -182
  97. package/reference/framework/memory.mdx +326 -326
  98. package/reference/framework/project-structure.mdx +282 -282
  99. package/reference/framework/tutorial-system.mdx +135 -135
  100. package/reference/getting-started.mdx +142 -142
  101. package/reference/index.mdx +106 -106
  102. package/reference/packages/core/src/README.md +14 -14
  103. package/reference/packages/core/src/business/README.md +2 -2
  104. package/reference/packages/core/src/knowledge/README.md +33 -32
  105. package/reference/packages/core/src/organization-model/README.md +149 -109
  106. package/reference/packages/core/src/test-utils/README.md +37 -37
  107. package/reference/packages/ui/src/api/README.md +18 -18
  108. package/reference/packages/ui/src/app/README.md +24 -24
  109. package/reference/packages/ui/src/auth/README.md +18 -18
  110. package/reference/packages/ui/src/components/README.md +24 -24
  111. package/reference/packages/ui/src/execution/README.md +16 -16
  112. package/reference/packages/ui/src/features/README.md +28 -28
  113. package/reference/packages/ui/src/graph/README.md +16 -16
  114. package/reference/packages/ui/src/hooks/README.md +23 -23
  115. package/reference/packages/ui/src/initialization/README.md +19 -19
  116. package/reference/packages/ui/src/knowledge/README.md +31 -31
  117. package/reference/packages/ui/src/organization/README.md +18 -18
  118. package/reference/packages/ui/src/profile/README.md +19 -19
  119. package/reference/packages/ui/src/provider/README.md +32 -32
  120. package/reference/packages/ui/src/router/README.md +18 -18
  121. package/reference/packages/ui/src/sse/README.md +13 -13
  122. package/reference/packages/ui/src/test-utils/README.md +7 -7
  123. package/reference/packages/ui/src/theme/README.md +23 -23
  124. package/reference/packages/ui/src/theme/presets/README.md +19 -19
  125. package/reference/packages/ui/src/types/README.md +16 -16
  126. package/reference/packages/ui/src/utils/README.md +18 -18
  127. package/reference/packages/ui/src/zustand/README.md +18 -18
  128. package/reference/platform-tools/adapters-integration.mdx +301 -301
  129. package/reference/platform-tools/adapters-platform.mdx +553 -553
  130. package/reference/platform-tools/index.mdx +217 -217
  131. package/reference/platform-tools/type-safety.mdx +82 -82
  132. package/reference/resources/index.mdx +349 -349
  133. package/reference/resources/patterns.mdx +449 -449
  134. package/reference/resources/types.mdx +116 -116
  135. package/reference/roadmap.mdx +165 -165
  136. package/reference/runtime.mdx +173 -173
  137. package/reference/scaffold/core/organization-graph.mdx +110 -89
  138. package/reference/scaffold/core/organization-model.mdx +226 -171
  139. package/reference/scaffold/index.mdx +67 -67
  140. package/reference/scaffold/operations/propagation-pipeline.md +77 -77
  141. package/reference/scaffold/operations/scaffold-maintenance.md +10 -10
  142. package/reference/scaffold/operations/workflow-recipes.md +138 -138
  143. package/reference/scaffold/recipes/add-a-feature.md +310 -88
  144. package/reference/scaffold/recipes/add-a-resource.md +137 -117
  145. package/reference/scaffold/recipes/customize-crm-actions.md +439 -439
  146. package/reference/scaffold/recipes/customize-knowledge-browser.md +384 -0
  147. package/reference/scaffold/recipes/customize-organization-model.md +281 -118
  148. package/reference/scaffold/recipes/extend-a-base-entity.md +8 -8
  149. package/reference/scaffold/recipes/extend-crm.md +40 -39
  150. package/reference/scaffold/recipes/extend-lead-gen.md +400 -401
  151. package/reference/scaffold/recipes/gate-by-feature-or-admin.md +118 -114
  152. package/reference/scaffold/recipes/index.md +47 -46
  153. package/reference/scaffold/recipes/query-the-knowledge-graph.md +227 -0
  154. package/reference/scaffold/reference/contracts.md +2389 -2121
  155. package/reference/scaffold/reference/feature-registry.md +9 -20
  156. package/reference/scaffold/reference/glossary.md +76 -76
  157. package/reference/scaffold/ui/composition-extensibility.mdx +233 -233
  158. package/reference/scaffold/ui/customization.md +243 -243
  159. package/reference/scaffold/ui/feature-flags-and-gating.md +46 -46
  160. package/reference/scaffold/ui/feature-shell.mdx +72 -72
  161. package/reference/scaffold/ui/recipes.md +221 -213
  162. package/reference/spine/spine-primer.md +96 -96
  163. package/reference/templates/index.mdx +47 -47
  164. package/reference/troubleshooting.mdx +223 -223
@@ -1,75 +1,75 @@
1
- ---
2
- title: Feature Shell & Provider Runtime
3
- description: Current feature shell contract for flat Organization Model features, manifests, route matching, sidebars, and breadcrumbs.
4
- ---
1
+ ---
2
+ title: System Shell & Provider Runtime
3
+ description: Current system shell contract for Organization Model systems, manifests, route matching, sidebars, and breadcrumbs.
4
+ ---
5
5
  <!-- @generated by packages/sdk/scripts/copy-reference-docs.mjs -- DO NOT EDIT -->
6
6
  <!-- Regenerate: pnpm scaffold:sync -->
7
7
 
8
-
9
- ## Overview
10
-
11
- The feature shell derives app navigation from `OrganizationModel.features`. Feature manifests provide implementation hooks such as icons and sidebars; they no longer own structural navigation.
12
-
13
- ## Source Of Truth
14
-
15
- - `packages/core/src/organization-model/defaults.ts` -- default flat feature list
16
- - `packages/core/src/organization-model/helpers.ts` -- `childrenOf`, `ancestorsOf`, `parentOf`, `topLevel`, `findByPath`
17
- - `packages/ui/src/features/registry/types.ts` -- `FeatureModule`
18
- - `packages/ui/src/provider/ElevasisFeaturesProvider.tsx` -- runtime resolver
19
- - `packages/ui/src/components/navigation/useBreadcrumbs.ts` -- breadcrumb derivation
20
-
21
- ## FeatureModule
22
-
23
- ```ts
24
- export interface FeatureModule {
25
- key: string
26
- featureId: string
27
- capabilityIds?: string[]
28
- icon?: FeatureIconComponent
29
- sidebar?: FeatureSidebarComponent
30
- organizationGraph?: { featureId: string }
31
- }
32
- ```
33
-
34
- `featureId` must match an Organization Model feature ID. Structural fields such as route lists, nav labels, and nested links belong on `OrganizationModel.features`.
35
-
36
- ## Shell Model
37
-
38
- `useElevasisFeatures()` exposes `shellModel`:
39
-
40
- ```ts
41
- {
42
- features,
43
- findByPath,
44
- findById,
45
- childrenOf,
46
- ancestorsOf,
47
- parentOf,
48
- topLevel,
49
- uiPositionFor,
50
- requiresAdminFor,
51
- devOnlyFor
52
- }
53
- ```
54
-
55
- Sidebar rendering walks `topLevel()` and `childrenOf(id)`. Breadcrumbs resolve `findByPath(location.pathname)` and then map `ancestorsOf(id)`.
56
-
57
- ## Access
58
-
59
- Feature access is keyed by Organization Model feature ID. `requiresAdmin` and `devOnly` inherit from ancestor feature nodes and are applied when deriving visible sidebar entries.
60
-
61
- Routes still need guards:
62
-
63
- ```tsx
64
- <ProtectedRoute>
65
- <FeatureGuard featureKey="sales.crm">
66
- <Outlet />
67
- </FeatureGuard>
68
- </ProtectedRoute>
69
- ```
70
-
71
- Use `AdminGuard` for pages that require platform-admin privileges.
72
-
73
- ## External Shells
74
-
75
- External templates pass `canonicalOrganizationModel` into `ElevasisFeaturesProvider` and derive sidebar links locally from `shellModel`. There is no separate nav config file to keep in sync.
8
+
9
+ ## Overview
10
+
11
+ The system shell derives app navigation from `OrganizationModel.systems`. System manifests provide implementation hooks such as icons and sidebars; they do not own structural navigation.
12
+
13
+ ## Source Of Truth
14
+
15
+ - `packages/core/src/organization-model/defaults.ts` -- default system list
16
+ - `packages/core/src/organization-model/helpers.ts` -- `childrenOf`, `ancestorsOf`, `parentOf`, `topLevel`, `findByPath`
17
+ - `packages/ui/src/features/registry/types.ts` -- `SystemModule`
18
+ - `packages/ui/src/provider/ElevasisSystemsProvider.tsx` -- runtime resolver
19
+ - `packages/ui/src/components/navigation/useBreadcrumbs.ts` -- breadcrumb derivation
20
+
21
+ ## SystemModule
22
+
23
+ ```ts
24
+ export interface SystemModule {
25
+ key: string
26
+ systemId: string
27
+ capabilityIds?: string[]
28
+ icon?: SystemIconComponent
29
+ sidebar?: SystemSidebarComponent
30
+ organizationGraph?: { systemId: string }
31
+ }
32
+ ```
33
+
34
+ `systemId` must match an Organization Model system ID. Structural fields such as route lists, nav labels, and nested links belong on `OrganizationModel.systems`.
35
+
36
+ ## Shell Model
37
+
38
+ `useElevasisSystems()` exposes `shellModel`:
39
+
40
+ ```ts
41
+ {
42
+ systems,
43
+ findByPath,
44
+ findById,
45
+ childrenOf,
46
+ ancestorsOf,
47
+ parentOf,
48
+ topLevel,
49
+ uiPositionFor,
50
+ requiresAdminFor,
51
+ devOnlyFor
52
+ }
53
+ ```
54
+
55
+ Sidebar rendering walks `topLevel()` and `childrenOf(id)`. Breadcrumbs resolve `findByPath(location.pathname)` and then map `ancestorsOf(id)`.
56
+
57
+ ## Access
58
+
59
+ System access is keyed by Organization Model system ID. `requiresAdmin` and `devOnly` inherit from ancestor system nodes and are applied when deriving visible sidebar entries.
60
+
61
+ Routes still need guards:
62
+
63
+ ```tsx
64
+ <ProtectedRoute>
65
+ <SystemGuard systemKey="sales.crm">
66
+ <Outlet />
67
+ </SystemGuard>
68
+ </ProtectedRoute>
69
+ ```
70
+
71
+ Use `AdminGuard` for pages that require platform-admin privileges.
72
+
73
+ ## External Shells
74
+
75
+ Host apps pass `SYSTEM_MANIFESTS` or their own `SystemModule[]` into `ElevasisSystemsProvider` and derive sidebar links locally from `shellModel`. There is no separate nav config file to keep in sync.
@@ -1,216 +1,224 @@
1
- ---
2
- title: UI Recipes
3
- description: Current recipes for adding pages, feature-gated routes, feature components, theme tokens, Organization Model sidebar entries, and executable resources.
4
- ---
1
+ ---
2
+ title: UI Recipes
3
+ description: Current recipes for adding pages, system-gated routes, system components, theme tokens, Organization Model sidebar entries, and executable resources.
4
+ ---
5
5
  <!-- @generated by packages/sdk/scripts/copy-reference-docs.mjs -- DO NOT EDIT -->
6
6
  <!-- Regenerate: pnpm scaffold:sync -->
7
7
 
8
-
9
- # UI Recipes
10
-
11
- ## 1. Add a Top-Level Page
12
-
13
- Create `ui/src/routes/my-feature.index.tsx`:
14
-
15
- ```tsx
16
- import { createFileRoute } from '@tanstack/react-router'
17
- import { ProtectedRoute } from '@/features/auth'
18
- import { AppShellContentContainer, AppTopbarAdjusterWrapper, PageContainer } from '@elevasis/ui/layout'
19
- import { MyFeaturePage } from '@/features/my-feature/components/MyFeaturePage'
20
-
21
- export const Route = createFileRoute('/my-feature/')({
22
- component: MyFeatureRouteComponent
23
- })
24
-
25
- function MyFeatureRouteComponent() {
26
- return (
27
- <ProtectedRoute>
28
- <AppTopbarAdjusterWrapper>
29
- <AppShellContentContainer>
30
- <PageContainer>
31
- <MyFeaturePage />
32
- </PageContainer>
33
- </AppShellContentContainer>
34
- </AppTopbarAdjusterWrapper>
35
- </ProtectedRoute>
36
- )
37
- }
38
- ```
39
-
40
- Add the sidebar entry as a feature node in `core/config/organization-model.ts`:
41
-
42
- ```ts
43
- features: [
44
- {
45
- id: 'my-feature',
46
- label: 'My Feature',
47
- enabled: true,
48
- path: '/my-feature',
49
- icon: 'star',
50
- uiPosition: 'sidebar-primary'
51
- }
52
- ]
53
- ```
54
-
55
- TanStack Router derives the path from the filename. The sidebar is derived from `OrganizationModel.features`.
56
-
57
- ## 2. Add a Feature-Gated Page
58
-
59
- Wrap the route with `FeatureGuard` and use the same feature ID as the org model node.
60
-
61
- ```tsx
62
- import { FeatureGuard } from '@/features/auth/guards/FeatureGuard'
63
-
64
- function MyFeatureRouteComponent() {
65
- return (
66
- <ProtectedRoute>
67
- <FeatureGuard featureKey="my-feature">
68
- <AppTopbarAdjusterWrapper>
69
- <AppShellContentContainer>
70
- <PageContainer>
71
- <MyFeaturePage />
72
- </PageContainer>
73
- </AppShellContentContainer>
74
- </AppTopbarAdjusterWrapper>
75
- </FeatureGuard>
76
- </ProtectedRoute>
77
- )
78
- }
79
- ```
80
-
81
- Set `enabled: false` in the feature node to hide it by default. Use `requiresAdmin: true` on the feature node plus `AdminGuard` in the route for admin-only pages.
82
-
83
- ## 3. Add a Nested Page
84
-
85
- Create a layout file for the section and child route files under the same directory.
86
-
87
- ```tsx
88
- import { createFileRoute, Outlet } from '@tanstack/react-router'
89
- import { ProtectedRoute } from '@/features/auth'
90
-
91
- export const Route = createFileRoute('/reporting')({
92
- component: ReportingLayoutComponent
93
- })
94
-
95
- function ReportingLayoutComponent() {
96
- return (
97
- <ProtectedRoute>
98
- <Outlet />
99
- </ProtectedRoute>
100
- )
101
- }
102
- ```
103
-
104
- Add dotted feature nodes for the sidebar hierarchy:
105
-
106
- ```ts
107
- { id: 'reporting', label: 'Reporting', enabled: true, uiPosition: 'sidebar-primary' },
108
- { id: 'reporting.overview', label: 'Overview', enabled: true, path: '/reporting/overview' },
109
- { id: 'reporting.reports', label: 'Reports', enabled: true, path: '/reporting/reports' }
110
- ```
111
-
112
- Containers omit `path`; leaves provide `path`.
113
-
114
- ## 4. Add a Feature-Scoped Component
115
-
116
- Use `ui/src/features/<name>/` when logic is shared across routes or owns local state.
117
-
118
- ```text
119
- ui/src/features/reporting/
120
- components/
121
- ReportingOverviewPage.tsx
122
- ReportCard.tsx
123
- hooks/
124
- useReports.ts
125
- utils/
126
- formatReportDate.ts
127
- types.ts
128
- ```
129
-
130
- Use `@/*` imports for app-local cross-feature imports and keep route layout concerns in route files.
131
-
132
- ## 5. Change Theme Tokens
133
-
134
- Edit `ui/src/config/theme.ts`.
135
-
136
- ```ts
137
- default: {
138
- label: 'Default',
139
- description: 'Project brand theme',
140
- colors: ['#2563eb', '#080808', '#f2f2f5'],
141
- dark: {
142
- primary: '#2563eb',
143
- primaryContrast: '#ffffff',
144
- background: '#050507',
145
- surface: '#0f0f14',
146
- surfaceHover: '#1a1a22',
147
- text: '#ffffff',
148
- textDimmed: '#b0b0c0',
149
- textSubtle: '#888898',
150
- border: 'rgba(255, 255, 255, 0.07)'
151
- }
152
- }
153
- ```
154
-
155
- All tokens flow into CSS variables. Change `defaultPreset` to alter the initial preset for new users.
156
-
157
- ## 6. Execute a Resource from a Surface
158
-
159
- Declare the resource descriptor in the Organization Model, then derive runtime metadata from that descriptor:
160
-
161
- ```ts
162
- // core/config/organization-model.ts
163
- import { defineResources } from '@elevasis/core/organization-model'
164
-
165
- export const resourceDescriptors = defineResources({
166
- writeNote: {
167
- id: 'write-note',
168
- kind: 'workflow',
169
- systemId: 'sys.sales',
170
- ownerRoleId: 'role-sales-ops',
171
- status: 'active'
172
- }
173
- })
174
-
175
- // operations/src/write-note/index.ts
176
- config: {
177
- resource: resourceDescriptors.writeNote,
178
- resourceId: resourceDescriptors.writeNote.id,
179
- name: 'Write Note',
180
- type: resourceDescriptors.writeNote.kind,
181
- version: '1.0.0',
182
- status: 'prod',
183
- links: [{ nodeId: 'feature:sales.crm', kind: 'operates-on' }],
184
- category: 'production'
185
- }
186
- ```
187
-
188
- Render the deployed workflow with `RunResourceButton`:
189
-
190
- ```tsx
191
- import { RunResourceButton } from '@elevasis/ui/components'
192
- import { writeNoteInputSchema } from '@core/types'
193
-
194
- export function DealPanel({ dealId }: { dealId: string }) {
195
- return (
196
- <RunResourceButton
197
- resourceId="write-note"
198
- resourceType="workflow"
199
- label="Write Note"
200
- getInput={() => ({
201
- schema: writeNoteInputSchema,
202
- defaults: { dealId }
203
- })}
204
- />
205
- )
206
- }
207
- ```
208
-
209
- `resourceDescriptors.writeNote.id` is the single authored ID. `RunResourceButton` still receives the deployed runtime ID. `links[].nodeId` binds the resource into the Organization Model graph. `category` drives operational filtering for production, diagnostic, internal, and testing resources.
210
-
211
- ## Cross-References
212
-
213
- - `./feature-flags-and-gating.md` -- feature and admin access model
214
- - `./feature-shell.mdx` -- provider and sidebar derivation
215
- - `./customization.md` -- feature sidebar customization
216
- - `ui/src/config/README.md` -- theme, background, and loader config
8
+
9
+ # UI Recipes
10
+
11
+ ## 1. Add a Top-Level Page
12
+
13
+ Create `ui/src/routes/my-system.index.tsx`:
14
+
15
+ ```tsx
16
+ import { createFileRoute } from '@tanstack/react-router'
17
+ import { ProtectedRoute } from '@/features/auth'
18
+ import { AppShellContentContainer, AppTopbarAdjusterWrapper, PageContainer } from '@elevasis/ui/layout'
19
+ import { MySystemPage } from '@/features/my-system/components/MySystemPage'
20
+
21
+ export const Route = createFileRoute('/my-system/')({
22
+ component: MySystemRouteComponent
23
+ })
24
+
25
+ function MySystemRouteComponent() {
26
+ return (
27
+ <ProtectedRoute>
28
+ <AppTopbarAdjusterWrapper>
29
+ <AppShellContentContainer>
30
+ <PageContainer>
31
+ <MySystemPage />
32
+ </PageContainer>
33
+ </AppShellContentContainer>
34
+ </AppTopbarAdjusterWrapper>
35
+ </ProtectedRoute>
36
+ )
37
+ }
38
+ ```
39
+
40
+ Add the sidebar entry as a system node in `core/config/organization-model.ts`:
41
+
42
+ ```ts
43
+ systems: {
44
+ systems: [
45
+ {
46
+ id: 'my-system',
47
+ label: 'My System',
48
+ enabled: true,
49
+ path: '/my-system',
50
+ icon: 'star',
51
+ uiPosition: 'sidebar-primary'
52
+ }
53
+ ]
54
+ }
55
+ ```
56
+
57
+ TanStack Router derives the path from the filename. The sidebar is derived from `OrganizationModel.systems`.
58
+
59
+ ## 2. Add a System-Gated Page
60
+
61
+ Wrap the route with `SystemGuard` and use the same system ID as the org model node.
62
+
63
+ ```tsx
64
+ import { SystemGuard } from '@elevasis/ui/features/auth'
65
+
66
+ function MySystemRouteComponent() {
67
+ return (
68
+ <ProtectedRoute>
69
+ <SystemGuard systemKey="my-system">
70
+ <AppTopbarAdjusterWrapper>
71
+ <AppShellContentContainer>
72
+ <PageContainer>
73
+ <MySystemPage />
74
+ </PageContainer>
75
+ </AppShellContentContainer>
76
+ </AppTopbarAdjusterWrapper>
77
+ </SystemGuard>
78
+ </ProtectedRoute>
79
+ )
80
+ }
81
+ ```
82
+
83
+ Set `enabled: false` in the system node to hide it by default. Use `requiresAdmin: true` on the system node plus `AdminGuard` in the route for admin-only pages.
84
+
85
+ ## 3. Add a Nested Page
86
+
87
+ Create a layout file for the section and child route files under the same directory.
88
+
89
+ ```tsx
90
+ import { createFileRoute, Outlet } from '@tanstack/react-router'
91
+ import { ProtectedRoute } from '@/features/auth'
92
+
93
+ export const Route = createFileRoute('/reporting')({
94
+ component: ReportingLayoutComponent
95
+ })
96
+
97
+ function ReportingLayoutComponent() {
98
+ return (
99
+ <ProtectedRoute>
100
+ <Outlet />
101
+ </ProtectedRoute>
102
+ )
103
+ }
104
+ ```
105
+
106
+ Add dotted system nodes for the sidebar hierarchy:
107
+
108
+ ```ts
109
+ { id: 'reporting', label: 'Reporting', enabled: true, uiPosition: 'sidebar-primary' },
110
+ { id: 'reporting.overview', label: 'Overview', enabled: true, path: '/reporting/overview' },
111
+ { id: 'reporting.reports', label: 'Reports', enabled: true, path: '/reporting/reports' }
112
+ ```
113
+
114
+ Containers omit `path`; leaves provide `path`.
115
+
116
+ ## 4. Add a System-Scoped Component
117
+
118
+ Use `ui/src/features/<name>/` when logic is shared across routes or owns local state.
119
+
120
+ ```text
121
+ ui/src/features/reporting/
122
+ components/
123
+ ReportingOverviewPage.tsx
124
+ ReportCard.tsx
125
+ hooks/
126
+ useReports.ts
127
+ utils/
128
+ formatReportDate.ts
129
+ types.ts
130
+ ```
131
+
132
+ Use `@/*` imports for app-local cross-system imports and keep route layout concerns in route files.
133
+
134
+ ## 5. Change Theme Tokens
135
+
136
+ Edit `ui/src/config/theme.ts`.
137
+
138
+ ```ts
139
+ default: {
140
+ label: 'Default',
141
+ description: 'Project brand theme',
142
+ colors: ['#2563eb', '#080808', '#f2f2f5'],
143
+ dark: {
144
+ primary: '#2563eb',
145
+ primaryContrast: '#ffffff',
146
+ background: '#050507',
147
+ surface: '#0f0f14',
148
+ surfaceHover: '#1a1a22',
149
+ text: '#ffffff',
150
+ textDimmed: '#b0b0c0',
151
+ textSubtle: '#888898',
152
+ border: 'rgba(255, 255, 255, 0.07)'
153
+ }
154
+ }
155
+ ```
156
+
157
+ All tokens flow into CSS variables. Change `defaultPreset` to alter the initial preset for new users.
158
+
159
+ ## 6. Execute a Resource from a Surface
160
+
161
+ Declare the resource descriptor in the Organization Model, then derive runtime metadata from that descriptor:
162
+
163
+ ```ts
164
+ // core/config/organization-model.ts
165
+ import { defineResources } from '@elevasis/core/organization-model'
166
+
167
+ export const resourceDescriptors = defineResources({
168
+ writeNote: {
169
+ id: 'write-note',
170
+ kind: 'workflow',
171
+ systemPath: 'sys.sales',
172
+ ownerRoleId: 'role-sales-ops',
173
+ status: 'active',
174
+ codeRefs: [
175
+ {
176
+ path: 'operations/src/write-note/index.ts',
177
+ role: 'entrypoint',
178
+ symbol: 'writeNoteWorkflow'
179
+ }
180
+ ]
181
+ }
182
+ })
183
+
184
+ // operations/src/write-note/index.ts
185
+ config: {
186
+ resource: resourceDescriptors.writeNote,
187
+ resourceId: resourceDescriptors.writeNote.id,
188
+ name: 'Write Note',
189
+ type: resourceDescriptors.writeNote.kind,
190
+ version: '1.0.0',
191
+ status: 'prod',
192
+ category: 'production'
193
+ }
194
+ ```
195
+
196
+ Render the deployed workflow with `RunResourceButton`:
197
+
198
+ ```tsx
199
+ import { RunResourceButton } from '@elevasis/ui/components'
200
+ import { writeNoteInputSchema } from '@core/types'
201
+
202
+ export function DealPanel({ dealId }: { dealId: string }) {
203
+ return (
204
+ <RunResourceButton
205
+ resourceId="write-note"
206
+ resourceType="workflow"
207
+ label="Write Note"
208
+ getInput={() => ({
209
+ schema: writeNoteInputSchema,
210
+ defaults: { dealId }
211
+ })}
212
+ />
213
+ )
214
+ }
215
+ ```
216
+
217
+ `resourceDescriptors.writeNote.id` is the single authored ID. `RunResourceButton` still receives the deployed runtime ID. `codeRefs` point agents and operators at implementation files, while `links[].nodeId` binds the resource into the Organization Model graph. `category` drives operational filtering for production, diagnostic, internal, and testing resources.
218
+
219
+ ## Cross-References
220
+
221
+ - `./feature-flags-and-gating.md` -- system and admin access model
222
+ - `./feature-shell.mdx` -- provider and sidebar derivation
223
+ - `./customization.md` -- system sidebar customization
224
+ - `ui/src/config/README.md` -- theme, background, and loader config