@elevasis/sdk 1.5.2 → 1.5.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 (63) hide show
  1. package/dist/cli.cjs +899 -57
  2. package/dist/index.d.ts +94 -110
  3. package/package.json +3 -3
  4. package/reference/_navigation.md +11 -1
  5. package/reference/_reference-manifest.json +70 -0
  6. package/reference/claude-config/commands/submit-issue.md +12 -0
  7. package/reference/claude-config/hooks/post-edit-validate.mjs +109 -0
  8. package/reference/claude-config/hooks/tool-failure-recovery.mjs +73 -0
  9. package/reference/claude-config/rules/deployment.md +57 -0
  10. package/reference/claude-config/rules/docs.md +26 -0
  11. package/reference/claude-config/rules/error-handling.md +56 -0
  12. package/reference/claude-config/rules/execution.md +40 -0
  13. package/reference/claude-config/rules/frontend.md +43 -0
  14. package/reference/claude-config/rules/observability.md +31 -0
  15. package/reference/claude-config/rules/organization-os.md +62 -0
  16. package/reference/claude-config/rules/platform.md +41 -0
  17. package/reference/claude-config/rules/shared-types.md +46 -0
  18. package/reference/claude-config/rules/task-tracking.md +47 -0
  19. package/reference/claude-config/scripts/statusline-command.js +18 -0
  20. package/reference/claude-config/settings.json +30 -0
  21. package/reference/claude-config/skills/deploy/SKILL.md +166 -0
  22. package/reference/claude-config/skills/dsp/SKILL.md +66 -0
  23. package/reference/claude-config/skills/elevasis/SKILL.md +239 -0
  24. package/reference/claude-config/skills/explore/SKILL.md +78 -0
  25. package/reference/claude-config/skills/project/SKILL.md +918 -0
  26. package/reference/claude-config/skills/save/SKILL.md +197 -0
  27. package/reference/claude-config/skills/setup/SKILL.md +210 -0
  28. package/reference/claude-config/skills/status/SKILL.md +60 -0
  29. package/reference/claude-config/skills/submit-issue/SKILL.md +179 -0
  30. package/reference/claude-config/skills/sync/SKILL.md +81 -0
  31. package/reference/cli.mdx +35 -20
  32. package/reference/deployment/index.mdx +6 -5
  33. package/reference/deployment/provided-features.mdx +62 -40
  34. package/reference/deployment/ui-execution.mdx +1 -2
  35. package/reference/framework/agent.mdx +50 -50
  36. package/reference/framework/index.mdx +13 -10
  37. package/reference/framework/project-structure.mdx +76 -70
  38. package/reference/packages/core/src/README.md +24 -17
  39. package/reference/packages/core/src/business/README.md +52 -0
  40. package/reference/packages/core/src/organization-model/README.md +25 -26
  41. package/reference/packages/ui/src/app/README.md +24 -0
  42. package/reference/packages/ui/src/provider/README.md +8 -7
  43. package/reference/platform-tools/type-safety.mdx +0 -10
  44. package/reference/roadmap.mdx +6 -4
  45. package/reference/scaffold/core/organization-graph.mdx +37 -28
  46. package/reference/scaffold/core/organization-model.mdx +34 -36
  47. package/reference/scaffold/index.mdx +14 -9
  48. package/reference/scaffold/operations/propagation-pipeline.md +133 -0
  49. package/reference/scaffold/operations/scaffold-maintenance.md +125 -0
  50. package/reference/scaffold/operations/workflow-recipes.md +18 -1
  51. package/reference/scaffold/recipes/add-a-feature.md +37 -21
  52. package/reference/scaffold/recipes/add-a-resource.md +16 -12
  53. package/reference/scaffold/recipes/customize-organization-model.md +400 -0
  54. package/reference/scaffold/recipes/extend-a-base-entity.md +140 -0
  55. package/reference/scaffold/recipes/gate-by-feature-or-admin.md +18 -12
  56. package/reference/scaffold/recipes/index.md +3 -3
  57. package/reference/scaffold/reference/contracts.md +11 -32
  58. package/reference/scaffold/reference/feature-registry.md +10 -9
  59. package/reference/scaffold/reference/glossary.md +14 -18
  60. package/reference/scaffold/ui/customization.md +2 -2
  61. package/reference/scaffold/ui/feature-flags-and-gating.md +40 -54
  62. package/reference/scaffold/ui/feature-shell.mdx +23 -24
  63. package/reference/scaffold/ui/recipes.md +118 -3
@@ -0,0 +1,125 @@
1
+ ---
2
+ title: Scaffold Maintenance
3
+ description: How scaffold documentation is organized, generated, and bundled into the SDK -- content placement map, auto-generation pipeline, and instructions for adding new scaffold docs.
4
+ ---
5
+
6
+ # Scaffold Maintenance
7
+
8
+ `🟢 Stable` -- Use this when adding or modifying scaffold documentation.
9
+
10
+ ---
11
+
12
+ ## Content Placement Model
13
+
14
+ Scaffold docs are co-located with their owning package and copied into the SDK reference at build time. This makes each package owner responsible for their docs and avoids a single monolithic directory.
15
+
16
+ ### Placement Rules
17
+
18
+ - If a doc explains a single abstraction boundary, **co-locate it** with the owning package.
19
+ - If a doc explains relationships between multiple abstractions, **centralize it** in `packages/sdk/docs/scaffold/`.
20
+ - If a doc can be derived from code or manifests, **generate it**.
21
+ - Hand-authored docs should point to generated maps rather than restating them.
22
+
23
+ ### Source-to-Destination Map
24
+
25
+ | Content | Source | SDK Reference Destination |
26
+ | --------------------------- | --------------------------------------------------------------- | --------------------------------------------- |
27
+ | Organization Model | `packages/core/src/organization-model/organization-model.mdx` | `scaffold/core/organization-model.mdx` |
28
+ | Organization Graph | `packages/core/src/organization-model/organization-graph.mdx` | `scaffold/core/organization-graph.mdx` |
29
+ | Glossary | `packages/core/src/reference/glossary.md` | `scaffold/reference/glossary.md` |
30
+ | Contracts (auto-gen) | `packages/core/src/reference/_generated/contracts.md` | `scaffold/reference/contracts.md` |
31
+ | UI Recipes | `packages/ui/src/scaffold/recipes.md` | `scaffold/ui/recipes.md` |
32
+ | Feature Flags & Gating | `packages/ui/src/scaffold/feature-flags-and-gating.md` | `scaffold/ui/feature-flags-and-gating.md` |
33
+ | Customization | `packages/ui/src/scaffold/customization.md` | `scaffold/ui/customization.md` |
34
+ | Feature Shell | `packages/ui/src/scaffold/feature-shell.mdx` | `scaffold/ui/feature-shell.mdx` |
35
+ | Composition & Extensibility | `packages/ui/src/scaffold/composition-extensibility.mdx` | `scaffold/ui/composition-extensibility.mdx` |
36
+ | Feature Registry (auto-gen) | `packages/ui/src/scaffold/_generated/feature-registry.md` | `scaffold/reference/feature-registry.md` |
37
+ | Scaffold Index | `packages/sdk/docs/scaffold/index.mdx` | `scaffold/index.mdx` |
38
+ | Pathway Recipes (4) | `packages/sdk/docs/scaffold/recipes/` | `scaffold/recipes/` |
39
+ | Workflow Recipes | `packages/sdk/docs/scaffold/operations/workflow-recipes.md` | `scaffold/operations/workflow-recipes.md` |
40
+ | Propagation Pipeline | `packages/sdk/docs/scaffold/operations/propagation-pipeline.md` | `scaffold/operations/propagation-pipeline.md` |
41
+ | This doc | `packages/sdk/docs/scaffold/operations/scaffold-maintenance.md` | `scaffold/operations/scaffold-maintenance.md` |
42
+
43
+ ---
44
+
45
+ ## Auto-Generation Pipeline
46
+
47
+ Two types of docs are auto-generated from source:
48
+
49
+ ### Contracts (`contracts.md`)
50
+
51
+ Generated by `scripts/monorepo/generate-scaffold-contracts.js` from TypeScript source types:
52
+
53
+ - `packages/core/src/organization-model/types.ts` -- Organization Model, Feature System
54
+ - `packages/ui/src/features/registry/types.ts` -- Feature Registry
55
+ - `packages/core/src/platform/registry/types.ts` -- Resource Registry, Deployment Spec
56
+
57
+ Output: `packages/core/src/reference/_generated/contracts.md`
58
+
59
+ ### Feature Registry (`feature-registry.md`)
60
+
61
+ Generated by `scripts/monorepo/generate-scaffold-feature-registry.js` from feature manifests:
62
+
63
+ - `packages/ui/src/features/*/manifest.ts` -- individual feature manifests
64
+ - `packages/core/src/organization-model/domains/features.ts` -- feature key definitions
65
+
66
+ Output: `packages/ui/src/scaffold/_generated/feature-registry.md`
67
+
68
+ ### Reference Artifacts
69
+
70
+ Generated by `scripts/monorepo/generate-reference-artifacts.js`:
71
+
72
+ - `packages/sdk/reference/_reference-manifest.json` -- machine-readable catalog of all reference entries
73
+ - `packages/sdk/reference/_navigation.md` -- navigation table
74
+ - `external/_template/docs/platform-navigation-map.md` -- cross-package reference map for external projects
75
+
76
+ ### Running Generators
77
+
78
+ ```bash
79
+ pnpm scaffold:generate # Run both generators
80
+ pnpm scaffold:sync # Generate + validate (the full loop)
81
+ pnpm sdk-ref:generate # Reference artifacts only
82
+ ```
83
+
84
+ Generated files should never be edited manually. If the output is wrong, fix the source types or the generator script.
85
+
86
+ ---
87
+
88
+ ## SDK Build Pipeline (Reference Copy)
89
+
90
+ `packages/sdk/scripts/copy-reference-docs.mjs` runs during `pnpm --filter @elevasis/sdk build` and has three phases:
91
+
92
+ 1. **Phase 1:** Copies SDK public docs from `apps/docs/content/docs/sdk/` with link rewriting and MDX escape stripping
93
+ 2. **Phase 2:** Copies package-owned reference docs declared in reference manifests
94
+ 3. **Phase 3:** Copies scaffold docs from co-located package sources using the `SCAFFOLD_COPIES` map
95
+
96
+ The output lands in `packages/sdk/reference/` which is included in the npm package's `files` array. External projects access it via `node_modules/@elevasis/sdk/reference/`.
97
+
98
+ ---
99
+
100
+ ## Adding New Scaffold Docs
101
+
102
+ 1. **Create the source doc** in the appropriate package:
103
+ - Core concepts: `packages/core/src/...`
104
+ - UI patterns: `packages/ui/src/scaffold/...`
105
+ - Cross-package or SDK-owned: `packages/sdk/docs/scaffold/...`
106
+
107
+ 2. **Add to `SCAFFOLD_COPIES`** in `packages/sdk/scripts/copy-reference-docs.mjs`:
108
+
109
+ ```javascript
110
+ { source: 'packages/sdk/docs/scaffold/operations/my-doc.md', target: 'scaffold/operations/my-doc.md' }
111
+ ```
112
+
113
+ 3. **Update the scaffold index** in `packages/sdk/docs/scaffold/index.mdx` with a link and description.
114
+
115
+ 4. **Rebuild the SDK** to verify: `pnpm --filter @elevasis/sdk build`
116
+
117
+ 5. **Update the permanent architecture docs** if the new doc covers a concept already referenced in `apps/docs/content/docs/technical/architecture/scaffold-reference.mdx`.
118
+
119
+ ---
120
+
121
+ ## Freshness Validation
122
+
123
+ External projects validate generated docs with `pnpm check:autogenerated-docs`, which now calls `pnpm exec elevasis-sdk validate-docs`. The legacy `scripts/validate-autogenerated-docs.mjs` file may still exist as a temporary compatibility shim in the template, but the SDK CLI is the canonical path.
124
+
125
+ At the monorepo level, `pnpm scaffold:sync` followed by `pnpm sync:verify` confirms that all artifacts are current and all downstream projects are consistent.
@@ -68,6 +68,23 @@ contract: {
68
68
  - Both runtimes (frontend and platform) import from `@foundation/types`, keeping validation consistent.
69
69
  - `@foundation/types` resolves to `foundations/types/index.ts` via the tsconfig path alias.
70
70
 
71
+ **Entity-backed workflows:** for workflows that operate on a domain entity, reference the entity contract rather than redeclaring it.
72
+
73
+ ```typescript
74
+ // foundations/types/index.ts
75
+ import { BaseDealSchema } from '@elevasis/core/entities'
76
+ import { DealSchema } from '@foundation/types/entities' // project-local extended version
77
+
78
+ export const closeDealInputSchema = z.object({
79
+ deal: DealSchema,
80
+ closedReason: z.string()
81
+ })
82
+
83
+ export type CloseDealInput = z.infer<typeof closeDealInputSchema>
84
+ ```
85
+
86
+ `DealSchema` is defined in `foundations/types/entities.ts` by extending `BaseDealSchema` with project-specific metadata. See [../recipes/extend-a-base-entity.md](../recipes/extend-a-base-entity.md) for the pattern.
87
+
71
88
  ### Steps
72
89
 
73
90
  Each step is a `WorkflowStep` with: `id`, `name`, `description`, `handler`, `inputSchema`, `outputSchema`, and `next`.
@@ -273,7 +290,7 @@ Use this pattern in React components and hooks. `apiRequest` automatically attac
273
290
  ```typescript
274
291
  // ui/src/features/notifications/hooks/useSendEmailNotification.ts
275
292
  import { useMutation } from '@tanstack/react-query'
276
- import { useApiClient } from '@/shared/api'
293
+ import { useApiClient } from '@/lib/hooks/useApiClient'
277
294
  import type { EmailNotificationInput, EmailNotificationOutput } from '@foundation/types'
278
295
 
279
296
  export function useSendEmailNotification() {
@@ -13,14 +13,14 @@ See [glossary.md](../reference/glossary.md) for term disambiguation throughout t
13
13
 
14
14
  ## 1. Decide the feature shape
15
15
 
16
- A shell feature requires an `OrganizationModelFeatureKey` to gate it. You have two options:
16
+ A shell feature requires a `feature.id` in the org model's `features[]` array to gate it. You have two options:
17
17
 
18
- - **Reuse an existing key** (e.g., `operations`, `monitoring`). The new feature shares an on/off toggle with other features using that key. Fine for sub-features within an existing domain.
19
- - **Add a new platform key** -- only possible if you are extending `OrganizationModelFeatureKey` itself, which requires a core package change. For template-local keys, use `FoundationLegacyFeatureKey` instead.
18
+ - **Reuse an existing feature** (e.g., `operations`, `monitoring`). The new shell module shares the on/off toggle with the existing feature entry. Fine for sub-modules within the same product area.
19
+ - **Add a new feature object** -- add an entry to the `features[]` array in `foundations/config/organization-model.ts`. This is always a template-local change; no core package change is required.
20
20
 
21
- For a genuinely new capability (e.g., `analytics`), you will extend `FoundationLegacyFeatureKey` in foundations so it becomes a valid `FoundationFeatureKey` and then declare it in the org model.
21
+ For a genuinely new capability (e.g., `analytics`), you add a feature object to the defaults array and author a matching manifest.
22
22
 
23
- See [glossary.md](../reference/glossary.md) under **Feature** (three contexts) and **OrganizationModelFeatureKey**.
23
+ See [glossary.md](../reference/glossary.md) under **Feature** (three contexts).
24
24
 
25
25
  ---
26
26
 
@@ -28,26 +28,42 @@ See [glossary.md](../reference/glossary.md) under **Feature** (three contexts) a
28
28
 
29
29
  File: `foundations/config/organization-model.ts`
30
30
 
31
- Add the key to `FoundationLegacyFeatureKey`, then declare it under `features.enabled`, `features.labels`, and the `featuresEnabled` resolver map.
31
+ Add a new feature object to the `features[]` array passed to `defineOrganizationModel`.
32
32
 
33
33
  ```ts
34
- // 1. Extend the local key union
35
- type FoundationLegacyFeatureKey = 'crm' | 'lead-gen' | 'projects' | 'analytics'
34
+ import { defineOrganizationModel } from '@elevasis/core/organization-model'
35
+ ```
36
36
 
37
- // 2. Enable in defineOrganizationModel call
38
- features: {
39
- enabled: { ..., analytics: false }, // start disabled
40
- labels: { ..., analytics: 'Analytics' }
41
- }
37
+ Use typed constants for the 7 platform features (`CRM_FEATURE_ID`, `LEAD_GEN_FEATURE_ID`, `PROJECTS_FEATURE_ID`, `OPERATIONS_FEATURE_ID`, `MONITORING_FEATURE_ID`, `SETTINGS_FEATURE_ID`, `SEO_FEATURE_ID`); use string literals for project-specific features you invent.
42
38
 
43
- // 3. Add to featuresEnabled resolver
44
- const featuresEnabled: Record<FoundationFeatureKey, boolean> = {
45
- ...
46
- analytics: resolvedOrganizationModel.features.enabled.analytics ?? false
47
- }
39
+ ```ts
40
+ const foundationOrganizationModelOverride = defineOrganizationModel({
41
+ features: [
42
+ // ... existing features
43
+ {
44
+ id: 'analytics',
45
+ label: 'Analytics',
46
+ enabled: false, // start disabled
47
+ entityIds: [],
48
+ surfaceIds: [],
49
+ resourceIds: [],
50
+ capabilityIds: []
51
+ }
52
+ ],
53
+ // ... rest of model
54
+ })
48
55
  ```
49
56
 
50
- Optionally, add a new domain entry and a navigation surface. See `OrganizationModelSemanticDomain` and `OrganizationModelSurface` shapes in [contracts.md](../reference/contracts.md).
57
+ Each field of the feature object:
58
+
59
+ - `id` -- unique stable identifier; this is the value `FeatureModule.featureId` must match
60
+ - `label` -- display name; used by nav label resolution when no manifest override is provided
61
+ - `enabled` -- org-wide default; `MembershipFeatureConfig.features` can override per member
62
+ - `entityIds`, `surfaceIds`, `resourceIds`, `capabilityIds` -- semantic references (leave empty to start)
63
+
64
+ No domain entry or separate key resolver is needed. The `features[]` array is the sole source of truth.
65
+
66
+ **Two-step pattern:** in a template-derived project, the `defineOrganizationModel` output is passed to `createFoundationOrganizationModel(override)` in `foundations/config/organization-model.ts`. The result exposes `.model`, `.canonical`, and `.homeLabel`. See `external/_template/foundations/config/organization-model.ts` for the canonical two-step example.
51
67
 
52
68
  ---
53
69
 
@@ -62,7 +78,7 @@ import { AnalyticsSidebar } from './sidebar'
62
78
 
63
79
  export const analyticsManifest: FeatureModule = {
64
80
  key: 'analytics',
65
- accessFeatureKey: 'analytics', // must match a FoundationFeatureKey
81
+ featureId: 'analytics', // must match a feature.id in the org model's features[] array
66
82
  navEntry: {
67
83
  label: 'Analytics',
68
84
  icon: IconChartBar,
@@ -75,7 +91,7 @@ export const analyticsManifest: FeatureModule = {
75
91
 
76
92
  Key fields:
77
93
 
78
- - `accessFeatureKey` -- the org-model key that gates the entire feature. The provider throws at startup if this key is not declared. See [glossary.md](../reference/glossary.md) under **accessFeatureKey**.
94
+ - `featureId` -- the org-model feature ID that gates the entire feature. The provider throws at startup if this ID is not found in the org model's `features[]` array. See [glossary.md](../reference/glossary.md) under **featureId**.
79
95
  - `sidebar` -- a component that renders the subshell sidebar. Compose from published primitives. See [customization.md](../ui/customization.md).
80
96
  - `subshellRoutes` -- every path that should activate this feature's sidebar.
81
97
 
@@ -52,6 +52,8 @@ export const myWorkflow: WorkflowDefinition = {
52
52
 
53
53
  Define input/output schemas in `foundations/types/index.ts`, not inline. Both runtimes import from `@foundation/types`. See [workflow-recipes.md](../operations/workflow-recipes.md) for Zod schema conventions and adapter usage (`llm`, `storage`, `scheduler`, `notifications` from `@elevasis/sdk/worker`).
54
54
 
55
+ **Entity-backed workflows:** if your workflow operates on a domain entity (Project, Deal, Company, etc.), define or reference the entity shape in `foundations/types/entities.ts` rather than declaring an ad-hoc shape here. The entity types extend base contracts from `@elevasis/core/entities` (`BaseProject`, `BaseDeal`, etc.) with project-specific metadata. See [./extend-a-base-entity.md](./extend-a-base-entity.md) for the pattern.
56
+
55
57
  ---
56
58
 
57
59
  ## 2. Register in the DeploymentSpec
@@ -89,18 +91,19 @@ If the resource triggers another resource, uses a human checkpoint, or depends o
89
91
  ```ts
90
92
  const org: DeploymentSpec = {
91
93
  // ...
92
- relationships: [
93
- {
94
- source: 'my-workflow',
95
- target: 'email-notification',
96
- type: 'triggers'
94
+ relationships: {
95
+ 'my-workflow': {
96
+ triggers: { workflows: ['email-notification'] }
97
97
  }
98
- ],
98
+ },
99
99
  humanCheckpoints: [
100
100
  {
101
- id: 'approval-gate',
102
- label: 'Approve before sending',
103
- routesTo: { resourceType: 'workflow', resourceId: 'my-workflow' }
101
+ resourceId: 'approval-gate',
102
+ name: 'Approve before sending',
103
+ type: 'human',
104
+ version: '1.0.0',
105
+ status: 'prod',
106
+ routesTo: { workflows: ['my-workflow'] }
104
107
  }
105
108
  ]
106
109
  }
@@ -117,9 +120,10 @@ To make the resource referenceable from the org model (so the Operations graph a
117
120
  ```ts
118
121
  resourceMappings: [
119
122
  {
123
+ id: 'my-workflow',
120
124
  resourceId: 'my-workflow',
121
125
  resourceType: 'workflow',
122
- domainId: 'operations',
126
+ domainIds: ['operations'],
123
127
  label: 'My Workflow'
124
128
  }
125
129
  ]
@@ -132,7 +136,7 @@ See `OrganizationModelResourceMapping` in [contracts.md](../reference/contracts.
132
136
  ## 5. Regenerate the topology map
133
137
 
134
138
  ```bash
135
- pnpm generate-resources
139
+ pnpm exec elevasis-sdk generate-resources
136
140
  ```
137
141
 
138
142
  Open `docs/resources.md` and confirm:
@@ -160,4 +164,4 @@ pnpm exec elevasis describe Elevasis/my-workflow
160
164
  pnpm exec elevasis exec Elevasis/my-workflow --input '{"field": "value"}'
161
165
  ```
162
166
 
163
- Use `--async` for long-running resources. Use `pnpm exec elevasis --prod exec ...` (flag before `exec`) for production. See [workflow-recipes.md](../operations/workflow-recipes.md) recipe 3 for the frontend trigger pattern.
167
+ Use `--async` for long-running resources. Use `pnpm exec elevasis --prod exec ...` (flag before `exec`) for production. See [workflow-recipes.md](../operations/workflow-recipes.md) recipe 3 for the low-level frontend trigger pattern (`useApiClient` + `useMutation`). For the higher-level UI pattern using `RunResourceButton`, `useExecuteResource`, and `ZodFormRenderer`, see [../ui/recipes.md](../ui/recipes.md) recipe 6.