@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,100 +1,100 @@
1
- # Codify Pipeline: Level A (Config-Only Edits)
2
-
3
- Level A is the codify pipeline for changes that land exclusively in
4
- `core/config/organization-model.ts`. No new TypeScript files are created. The entire
5
- ceremony is: snapshot current file, propose the edit, write the edit, validate, and roll back on
6
- failure.
7
-
8
- This pipeline is called by domain operations (identity, customers, offerings, roles, goals,
9
- techStack, features, labels) after the user has confirmed the proposed change. The caller provides
10
- the specific field/block being changed and the proposed new value.
11
-
12
- ---
13
-
14
- ## Pipeline
15
-
16
- ### Step 1: Snapshot
17
-
18
- Before any write, read `core/config/organization-model.ts` and keep the full file content
19
- in memory as the rollback snapshot. Do not write any file during this step.
20
-
21
- ```
22
- Read("core/config/organization-model.ts")
23
- -- store as ROLLBACK_SNAPSHOT
24
- ```
25
-
26
- ### Step 2: Apply the edit
27
-
28
- Use the Edit tool to apply the caller's proposed change to
29
- `core/config/organization-model.ts`.
30
-
31
- Rules for the edit:
32
-
33
- - Edit only the specific field or block the caller specified. Do not reformat or restructure
34
- unrelated sections.
35
- - Preserve all other keys in `defineOrganizationModel({...})` exactly as they are.
36
- - Maintain the existing code style (trailing commas, quote style, indentation) of the file.
37
- - If the target field does not yet exist in the adapter call, add it as a new property in the
38
- appropriate position (following the declared domain order in the schema).
39
-
40
- ### Step 3: TypeScript type-check
41
-
42
- Run the type-check for the operations package:
43
-
44
- ```bash
45
- pnpm -C operations check-types
46
- ```
47
-
48
- Capture stdout and stderr. If the command exits non-zero, proceed to Step 5 (rollback).
49
-
50
- ### Step 4: Runtime schema validation
51
-
52
- Confirm that the adapter's output passes `OrganizationModelSchema.parse()`. The adapter calls
53
- `resolveOrganizationModel()` internally, which merges defaults with overrides and then parses the
54
- result. A successful `check-types` pass is strong evidence that the schema is valid, but
55
- cross-reference checks (segment ID refs in offerings, role reporting refs, period ordering in
56
- goals) are runtime-only.
57
-
58
- If the project exposes a validation script (e.g. `pnpm -C operations check`), run that too:
59
-
60
- ```bash
61
- pnpm -C operations check
62
- ```
63
-
64
- If either validation step fails, proceed to Step 5 (rollback).
65
-
66
- ### Step 5: Rollback (on failure only)
67
-
68
- If Step 3 or Step 4 failed:
69
-
70
- 1. Write the ROLLBACK_SNAPSHOT content back to `core/config/organization-model.ts`
71
- verbatim (use the Write tool with the exact snapshot content).
72
- 2. Confirm the file has been restored by checking that the content matches the snapshot.
73
- 3. Return the error message to the caller.
74
-
75
- The caller is responsible for reporting the rollback to the user.
76
-
77
- ### Step 6: Success signal
78
-
79
- If Steps 3 and 4 both passed, return a success signal to the caller with:
80
-
81
- - The fields changed
82
- - `Type-check: PASS`
83
- - `Schema validation: PASS`
84
-
85
- The caller formats and presents the final report.
86
-
87
- ---
88
-
89
- ## Caller Contract
90
-
91
- Callers must provide before invoking this pipeline:
92
-
93
- - **Target file:** always `core/config/organization-model.ts`
94
- - **Target block:** the specific domain key or sub-key being changed (e.g. `identity`,
95
- `customers.segments`, `roles.roles`, `resources.entries[id="hubspot"]`)
96
- - **Proposed value:** the new TypeScript literal to write for that block
97
- - **Confirmed:** the user has already said yes to the proposed change
98
-
99
- This pipeline does not ask the user any questions. All confirmation happens in the domain
100
- operation before this pipeline is invoked.
1
+ # Codify Pipeline: Level A (Config-Only Edits)
2
+
3
+ Level A is the codify pipeline for changes that land exclusively in
4
+ `core/config/organization-model.ts`. No new TypeScript files are created. The entire
5
+ ceremony is: snapshot current file, propose the edit, write the edit, validate, and roll back on
6
+ failure.
7
+
8
+ This pipeline is called by domain operations (identity, customers, offerings, roles, goals,
9
+ techStack, systems, actions, labels, and legacy feature compatibility) after the user has confirmed the proposed change. The caller provides
10
+ the specific field/block being changed and the proposed new value.
11
+
12
+ ---
13
+
14
+ ## Pipeline
15
+
16
+ ### Step 1: Snapshot
17
+
18
+ Before any write, read `core/config/organization-model.ts` and keep the full file content
19
+ in memory as the rollback snapshot. Do not write any file during this step.
20
+
21
+ ```
22
+ Read("core/config/organization-model.ts")
23
+ -- store as ROLLBACK_SNAPSHOT
24
+ ```
25
+
26
+ ### Step 2: Apply the edit
27
+
28
+ Use the Edit tool to apply the caller's proposed change to
29
+ `core/config/organization-model.ts`.
30
+
31
+ Rules for the edit:
32
+
33
+ - Edit only the specific field or block the caller specified. Do not reformat or restructure
34
+ unrelated sections.
35
+ - Preserve all other keys in `defineOrganizationModel({...})` exactly as they are.
36
+ - Maintain the existing code style (trailing commas, quote style, indentation) of the file.
37
+ - If the target field does not yet exist in the adapter call, add it as a new property in the
38
+ appropriate position (following the declared domain order in the schema).
39
+
40
+ ### Step 3: TypeScript type-check
41
+
42
+ Run the type-check for the operations package:
43
+
44
+ ```bash
45
+ pnpm -C operations check-types
46
+ ```
47
+
48
+ Capture stdout and stderr. If the command exits non-zero, proceed to Step 5 (rollback).
49
+
50
+ ### Step 4: Runtime schema validation
51
+
52
+ Confirm that the adapter's output passes `OrganizationModelSchema.parse()`. The adapter calls
53
+ `resolveOrganizationModel()` internally, which merges defaults with overrides and then parses the
54
+ result. A successful `check-types` pass is strong evidence that the schema is valid, but
55
+ cross-reference checks (segment ID refs in offerings, role reporting refs, period ordering in
56
+ goals) are runtime-only.
57
+
58
+ If the project exposes a validation script (e.g. `pnpm -C operations check`), run that too:
59
+
60
+ ```bash
61
+ pnpm -C operations check
62
+ ```
63
+
64
+ If either validation step fails, proceed to Step 5 (rollback).
65
+
66
+ ### Step 5: Rollback (on failure only)
67
+
68
+ If Step 3 or Step 4 failed:
69
+
70
+ 1. Write the ROLLBACK_SNAPSHOT content back to `core/config/organization-model.ts`
71
+ verbatim (use the Write tool with the exact snapshot content).
72
+ 2. Confirm the file has been restored by checking that the content matches the snapshot.
73
+ 3. Return the error message to the caller.
74
+
75
+ The caller is responsible for reporting the rollback to the user.
76
+
77
+ ### Step 6: Success signal
78
+
79
+ If Steps 3 and 4 both passed, return a success signal to the caller with:
80
+
81
+ - The fields changed
82
+ - `Type-check: PASS`
83
+ - `Schema validation: PASS`
84
+
85
+ The caller formats and presents the final report.
86
+
87
+ ---
88
+
89
+ ## Caller Contract
90
+
91
+ Callers must provide before invoking this pipeline:
92
+
93
+ - **Target file:** always `core/config/organization-model.ts`
94
+ - **Target block:** the specific domain key or sub-key being changed (e.g. `identity`,
95
+ `customers.segments`, `roles.roles`, `resources.hubspot`)
96
+ - **Proposed value:** the new TypeScript literal to write for that block
97
+ - **Confirmed:** the user has already said yes to the proposed change
98
+
99
+ This pipeline does not ask the user any questions. All confirmation happens in the domain
100
+ operation before this pipeline is invoked.
@@ -1,158 +1,159 @@
1
- # Codify Pipeline: Level B (New Extension TypeScript Files)
2
-
3
- Level B is the codify pipeline for changes that require creating a new TypeScript file under
4
- `core/config/extensions/`. This pipeline is used when the user wants to add a custom
5
- feature, a custom entity type, or any structural addition that cannot be expressed as a simple
6
- field override in `core/config/organization-model.ts`.
7
-
8
- Level B is **only offered when the user explicitly asks** for something that requires a new file.
9
- Never silently escalate from Level A to Level B. If Level A is sufficient, use it.
10
-
11
- ---
12
-
13
- ## When Level B applies
14
-
15
- - Adding a custom feature that does not exist in the platform defaults (new `FeatureSchema` entry
16
- with a custom ID, manifest wiring, and route references)
17
- - Adding a custom entity extension (new Zod schema extending a base entity type)
18
- - Any structural addition the caller's domain operation has determined cannot be expressed as a
19
- field value in the existing adapter
20
-
21
- The calling operation (e.g. `features.md`) is responsible for deciding when Level B is needed
22
- and for confirming the intent with the user before invoking this pipeline.
23
-
24
- ---
25
-
26
- ## Pipeline
27
-
28
- ### Step 1: Snapshot all files that will be touched
29
-
30
- Before any write, read and snapshot:
31
-
32
- 1. `core/config/organization-model.ts` (always touched for wiring)
33
- 2. The target extension file path (if it already exists -- confirm overwrite with user)
34
-
35
- ```
36
- Read("core/config/organization-model.ts") -- store as ROLLBACK_ADAPTER
37
- Read("core/config/extensions/{target}.ts") -- store as ROLLBACK_EXTENSION (if exists)
38
- ```
39
-
40
- The target extension file path follows the naming convention:
41
- `core/config/extensions/{kebab-case-feature-id}.ts`
42
-
43
- ### Step 2: Scaffold the extension file
44
-
45
- Create `core/config/extensions/{id}.ts` using the Write tool.
46
-
47
- The file shape depends on the extension type:
48
-
49
- **Custom feature (most common Level B case):**
50
-
51
- ```typescript
52
- /**
53
- * {Feature label} feature extension.
54
- * Registered in core/config/organization-model.ts.
55
- */
56
- import type { OrganizationModelFeature } from '@elevasis/core/organization-model'
57
-
58
- export const {FEATURE_CONST}: OrganizationModelFeature = {
59
- id: '{feature-id}',
60
- label: '{Feature Label}',
61
- description: '{optional description}',
62
- enabled: true,
63
- entityIds: [],
64
- surfaceIds: [],
65
- resourceIds: [],
66
- capabilityIds: [],
67
- }
68
- ```
69
-
70
- Replace `{FEATURE_CONST}` with the SCREAMING_SNAKE_CASE version of the feature ID
71
- (e.g. `CLIENT_PORTAL_FEATURE`).
72
-
73
- The caller provides the exact field values based on what the user confirmed.
74
-
75
- ### Step 3: Wire the extension into the adapter
76
-
77
- Edit `core/config/organization-model.ts` to:
78
-
79
- 1. Import the new constant from the extension file.
80
- 2. Add it to the `features` array in the `defineOrganizationModel({...})` call.
81
-
82
- Example import addition:
83
-
84
- ```typescript
85
- import { CLIENT_PORTAL_FEATURE } from './extensions/client-portal'
86
- ```
87
-
88
- Example features array addition:
89
-
90
- ```typescript
91
- features: [
92
- ...existingFeatures,
93
- CLIENT_PORTAL_FEATURE,
94
- ],
95
- ```
96
-
97
- ### Step 4: TypeScript type-check
98
-
99
- ```bash
100
- pnpm -C operations check-types
101
- ```
102
-
103
- Capture stdout and stderr. If the command exits non-zero, proceed to Step 6 (rollback).
104
-
105
- ### Step 5: Runtime schema validation
106
-
107
- ```bash
108
- pnpm -C operations check
109
- ```
110
-
111
- If either check fails, proceed to Step 6 (rollback).
112
-
113
- ### Step 6: Rollback (on failure only)
114
-
115
- If Step 4 or Step 5 failed:
116
-
117
- 1. Restore `core/config/organization-model.ts` from ROLLBACK_ADAPTER.
118
- 2. If the extension file did not previously exist, delete it. If it previously existed, restore
119
- from ROLLBACK_EXTENSION.
120
- 3. Re-run `pnpm -C operations check-types` to confirm the restore is clean. If the restore
121
- itself fails type-check, report both the original error and the restore state to the user --
122
- do not silently leave the project in a broken state.
123
- 4. Return the error message to the caller.
124
-
125
- ### Step 7: Success signal
126
-
127
- If Steps 4 and 5 both passed, return a success signal to the caller with:
128
-
129
- - Extension file path created
130
- - Adapter wiring changes (import + features array entry)
131
- - `Type-check: PASS`
132
- - `Schema validation: PASS`
133
-
134
- The caller formats and presents the final report to the user.
135
-
136
- ---
137
-
138
- ## Caller Contract
139
-
140
- Callers must provide before invoking this pipeline:
141
-
142
- - **Extension file path:** `core/config/extensions/{id}.ts`
143
- - **Extension file content:** the full TypeScript content for the new file
144
- - **Adapter changes:** the exact import line and features-array addition to write into the adapter
145
- - **Confirmed:** the user has already said yes to the proposed change and explicitly requested
146
- a new extension file
147
-
148
- This pipeline does not ask the user any questions. All confirmation and escalation decisions
149
- happen in the domain operation before this pipeline is invoked.
150
-
151
- ---
152
-
153
- ## Constraint: Extension files are Tier 3 (never synced)
154
-
155
- Files under `core/config/extensions/` are Tier 3 -- project-specific, never overwritten
156
- by `/external sync`. This means custom features and entity extensions survive template upgrades
157
- automatically. Do not put platform-default overrides in extension files; those belong directly in
158
- `core/config/organization-model.ts` (Tier 2, merge-aware).
1
+ # Codify Pipeline: Level B (New Extension TypeScript Files)
2
+
3
+ Level B is the codify pipeline for changes that require creating a new TypeScript file under
4
+ `core/config/extensions/`. This pipeline is used when the user wants to add or extend a System,
5
+ add an Action, add a custom entity type, or make any structural addition that cannot be expressed as a simple
6
+ field override in `core/config/organization-model.ts`.
7
+
8
+ Level B is **only offered when the user explicitly asks** for something that requires a new file.
9
+ Never silently escalate from Level A to Level B. If Level A is sufficient, use it.
10
+
11
+ ---
12
+
13
+ ## When Level B applies
14
+
15
+ - Adding or extending a System that does not exist in the platform defaults, including routing,
16
+ manifest wiring, and route references
17
+ - Adding an Action that is invokable by a workflow, agent, command, or UI trigger
18
+ - Adding a custom entity extension (new Zod schema extending a base entity type)
19
+ - Any structural addition the caller's domain operation has determined cannot be expressed as a
20
+ field value in the existing adapter
21
+
22
+ The calling operation (or the legacy compatibility notes in `features.md`) is responsible for deciding when Level B is needed
23
+ and for confirming the intent with the user before invoking this pipeline.
24
+
25
+ ---
26
+
27
+ ## Pipeline
28
+
29
+ ### Step 1: Snapshot all files that will be touched
30
+
31
+ Before any write, read and snapshot:
32
+
33
+ 1. `core/config/organization-model.ts` (always touched for wiring)
34
+ 2. The target extension file path (if it already exists -- confirm overwrite with user)
35
+
36
+ ```
37
+ Read("core/config/organization-model.ts") -- store as ROLLBACK_ADAPTER
38
+ Read("core/config/extensions/{target}.ts") -- store as ROLLBACK_EXTENSION (if exists)
39
+ ```
40
+
41
+ The target extension file path follows the naming convention:
42
+ `core/config/extensions/{kebab-case-system-or-action-id}.ts`
43
+
44
+ ### Step 2: Scaffold the extension file
45
+
46
+ Create `core/config/extensions/{id}.ts` using the Write tool.
47
+
48
+ The file shape depends on the extension type:
49
+
50
+ **Custom system/action extension (common Level B case):**
51
+
52
+ ```typescript
53
+ /**
54
+ * {System or action label} extension.
55
+ * Registered in core/config/organization-model.ts.
56
+ */
57
+ import type { OrganizationModelSystem } from '@elevasis/core/organization-model'
58
+
59
+ export const {SYSTEM_CONST}: OrganizationModelSystem = {
60
+ id: '{system-or-action-id}',
61
+ label: '{System or Action Label}',
62
+ description: '{optional description}',
63
+ enabled: true,
64
+ entityIds: [],
65
+ surfaceIds: [],
66
+ resourceIds: [],
67
+ actionIds: [],
68
+ }
69
+ ```
70
+
71
+ Replace `{SYSTEM_CONST}` with the SCREAMING_SNAKE_CASE version of the system or action ID
72
+ (e.g. `CLIENT_PORTAL_SYSTEM`).
73
+
74
+ The caller provides the exact field values based on what the user confirmed.
75
+
76
+ ### Step 3: Wire the extension into the adapter
77
+
78
+ Edit `core/config/organization-model.ts` to:
79
+
80
+ 1. Import the new constant from the extension file.
81
+ 2. Add it to the appropriate `systems` or `actions` collection in the `defineOrganizationModel({...})` call.
82
+
83
+ Example import addition:
84
+
85
+ ```typescript
86
+ import { CLIENT_PORTAL_SYSTEM } from './extensions/client-portal'
87
+ ```
88
+
89
+ Example system collection addition:
90
+
91
+ ```typescript
92
+ systems: [
93
+ ...existingSystems,
94
+ CLIENT_PORTAL_SYSTEM,
95
+ ],
96
+ ```
97
+
98
+ ### Step 4: TypeScript type-check
99
+
100
+ ```bash
101
+ pnpm -C operations check-types
102
+ ```
103
+
104
+ Capture stdout and stderr. If the command exits non-zero, proceed to Step 6 (rollback).
105
+
106
+ ### Step 5: Runtime schema validation
107
+
108
+ ```bash
109
+ pnpm -C operations check
110
+ ```
111
+
112
+ If either check fails, proceed to Step 6 (rollback).
113
+
114
+ ### Step 6: Rollback (on failure only)
115
+
116
+ If Step 4 or Step 5 failed:
117
+
118
+ 1. Restore `core/config/organization-model.ts` from ROLLBACK_ADAPTER.
119
+ 2. If the extension file did not previously exist, delete it. If it previously existed, restore
120
+ from ROLLBACK_EXTENSION.
121
+ 3. Re-run `pnpm -C operations check-types` to confirm the restore is clean. If the restore
122
+ itself fails type-check, report both the original error and the restore state to the user --
123
+ do not silently leave the project in a broken state.
124
+ 4. Return the error message to the caller.
125
+
126
+ ### Step 7: Success signal
127
+
128
+ If Steps 4 and 5 both passed, return a success signal to the caller with:
129
+
130
+ - Extension file path created
131
+ - Adapter wiring changes (import + systems/actions collection entry)
132
+ - `Type-check: PASS`
133
+ - `Schema validation: PASS`
134
+
135
+ The caller formats and presents the final report to the user.
136
+
137
+ ---
138
+
139
+ ## Caller Contract
140
+
141
+ Callers must provide before invoking this pipeline:
142
+
143
+ - **Extension file path:** `core/config/extensions/{id}.ts`
144
+ - **Extension file content:** the full TypeScript content for the new file
145
+ - **Adapter changes:** the exact import line and systems/actions collection addition to write into the adapter
146
+ - **Confirmed:** the user has already said yes to the proposed change and explicitly requested
147
+ a new extension file
148
+
149
+ This pipeline does not ask the user any questions. All confirmation and escalation decisions
150
+ happen in the domain operation before this pipeline is invoked.
151
+
152
+ ---
153
+
154
+ ## Constraint: Extension files are Tier 3 (never synced)
155
+
156
+ Files under `core/config/extensions/` are Tier 3 -- project-specific, never overwritten
157
+ by `/external sync`. This means custom systems, actions, and entity extensions survive template upgrades
158
+ automatically. Do not put platform-default overrides in extension files; those belong directly in
159
+ `core/config/organization-model.ts` (Tier 2, merge-aware).