@elementumai/edk 0.8.0-preview.11 → 0.8.2-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/README.md +510 -324
  2. package/dist-sdk/src/catalog/ai-provider-models.d.ts +30 -0
  3. package/dist-sdk/src/catalog/ai-provider-models.js +63 -0
  4. package/dist-sdk/src/catalog/factories.d.ts +56 -3
  5. package/dist-sdk/src/catalog/factories.js +83 -4
  6. package/dist-sdk/src/catalog/from-authoring.js +19 -2
  7. package/dist-sdk/src/catalog/index.d.ts +3 -2
  8. package/dist-sdk/src/catalog/index.js +3 -2
  9. package/dist-sdk/src/catalog/org.d.ts +1 -1
  10. package/dist-sdk/src/catalog/org.js +134 -50
  11. package/dist-sdk/src/catalog/render.d.ts +13 -1
  12. package/dist-sdk/src/catalog/render.js +21 -4
  13. package/dist-sdk/src/catalog/token.js +18 -0
  14. package/dist-sdk/src/catalog/types.d.ts +75 -3
  15. package/dist-sdk/src/catalog/types.js +3 -0
  16. package/dist-sdk/src/core/system-fields.d.ts +2 -0
  17. package/dist-sdk/src/core/system-fields.js +2 -0
  18. package/dist-sdk/src/core/types/ai-provider.d.ts +10 -23
  19. package/dist-sdk/src/core/types/ai-provider.js +1 -25
  20. package/dist-sdk/src/core/types/app.d.ts +26 -1
  21. package/dist-sdk/src/engine/build/context.d.ts +58 -0
  22. package/dist-sdk/src/engine/build/context.js +11 -1
  23. package/dist-sdk/src/engine/build/source-context.d.ts +45 -0
  24. package/dist-sdk/src/engine/build/source-context.js +23 -0
  25. package/dist-sdk/src/engine/pull/context.d.ts +15 -0
  26. package/dist-sdk/src/engine/pull/org.d.ts +10 -0
  27. package/dist-sdk/src/engine/pull/org.js +34 -4
  28. package/dist-sdk/src/engine/tf/index.d.ts +2 -2
  29. package/dist-sdk/src/engine/tf/index.js +2 -2
  30. package/dist-sdk/src/engine/tf/labels.d.ts +54 -0
  31. package/dist-sdk/src/engine/tf/labels.js +75 -0
  32. package/dist-sdk/src/engine/tf/parse.d.ts +15 -0
  33. package/dist-sdk/src/engine/tf/parse.js +162 -0
  34. package/dist-sdk/src/entities/access-policy/build.d.ts +26 -0
  35. package/dist-sdk/src/entities/access-policy/build.js +7 -0
  36. package/dist-sdk/src/entities/access-policy/filter.d.ts +61 -0
  37. package/dist-sdk/src/entities/access-policy/filter.js +83 -0
  38. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +66 -0
  39. package/dist-sdk/src/entities/access-policy/from-tf.js +187 -0
  40. package/dist-sdk/src/entities/access-policy/module.d.ts +3 -0
  41. package/dist-sdk/src/entities/access-policy/module.js +17 -0
  42. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +43 -0
  43. package/dist-sdk/src/entities/access-policy/to-tf.js +164 -0
  44. package/dist-sdk/src/entities/access-policy/types.d.ts +4 -0
  45. package/dist-sdk/src/entities/access-policy/types.js +10 -0
  46. package/dist-sdk/src/entities/agent/build.d.ts +2 -0
  47. package/dist-sdk/src/entities/agent/build.js +1 -0
  48. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +38 -3
  49. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +257 -32
  50. package/dist-sdk/src/entities/agent/from-tf.d.ts +29 -9
  51. package/dist-sdk/src/entities/agent/from-tf.js +146 -19
  52. package/dist-sdk/src/entities/agent/index.d.ts +1 -1
  53. package/dist-sdk/src/entities/agent/module.js +14 -4
  54. package/dist-sdk/src/entities/agent/to-tf.d.ts +46 -1
  55. package/dist-sdk/src/entities/agent/to-tf.js +160 -14
  56. package/dist-sdk/src/entities/agent/tools.d.ts +88 -9
  57. package/dist-sdk/src/entities/agent/tools.js +46 -7
  58. package/dist-sdk/src/entities/agent-a2a-skill/from-tf.d.ts +17 -0
  59. package/dist-sdk/src/entities/agent-a2a-skill/from-tf.js +64 -0
  60. package/dist-sdk/src/entities/agent-a2a-skill/module.d.ts +4 -0
  61. package/dist-sdk/src/entities/agent-a2a-skill/module.js +14 -0
  62. package/dist-sdk/src/entities/agent-a2a-skill/to-tf.d.ts +40 -0
  63. package/dist-sdk/src/entities/agent-a2a-skill/to-tf.js +47 -0
  64. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +51 -4
  65. package/dist-sdk/src/entities/agent-tool/from-tf.js +131 -35
  66. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +11 -4
  67. package/dist-sdk/src/entities/agent-tool/to-tf.js +176 -30
  68. package/dist-sdk/src/entities/agent-tool/types.d.ts +5 -4
  69. package/dist-sdk/src/entities/agent-tool/types.js +38 -6
  70. package/dist-sdk/src/entities/app/build.d.ts +91 -13
  71. package/dist-sdk/src/entities/app/build.js +63 -5
  72. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +3 -0
  73. package/dist-sdk/src/entities/app/from-tf.d.ts +1 -1
  74. package/dist-sdk/src/entities/app/from-tf.js +32 -22
  75. package/dist-sdk/src/entities/app/index.d.ts +4 -1
  76. package/dist-sdk/src/entities/app/index.js +2 -1
  77. package/dist-sdk/src/entities/app/module.js +10 -2
  78. package/dist-sdk/src/entities/app/to-tf.d.ts +5 -0
  79. package/dist-sdk/src/entities/app/to-tf.js +45 -4
  80. package/dist-sdk/src/entities/automation/build.d.ts +57 -13
  81. package/dist-sdk/src/entities/automation/build.js +62 -42
  82. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +25 -8
  83. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +16 -1
  84. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +206 -47
  85. package/dist-sdk/src/entities/automation/filter.d.ts +37 -3
  86. package/dist-sdk/src/entities/automation/filter.js +54 -3
  87. package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -27
  88. package/dist-sdk/src/entities/automation/from-tf.js +1344 -222
  89. package/dist-sdk/src/entities/automation/index.d.ts +4 -0
  90. package/dist-sdk/src/entities/automation/index.js +4 -0
  91. package/dist-sdk/src/entities/automation/module.js +29 -32
  92. package/dist-sdk/src/entities/automation/operators.d.ts +29 -2
  93. package/dist-sdk/src/entities/automation/operators.js +27 -1
  94. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +19 -0
  95. package/dist-sdk/src/entities/automation/output-key-wire-name.js +24 -0
  96. package/dist-sdk/src/entities/automation/script-code.d.ts +10 -21
  97. package/dist-sdk/src/entities/automation/script-code.js +272 -5
  98. package/dist-sdk/src/entities/automation/tasks.d.ts +125 -19
  99. package/dist-sdk/src/entities/automation/tasks.js +83 -15
  100. package/dist-sdk/src/entities/automation/to-tf.d.ts +10 -29
  101. package/dist-sdk/src/entities/automation/to-tf.js +1291 -230
  102. package/dist-sdk/src/entities/automation/triggers.d.ts +9 -1
  103. package/dist-sdk/src/entities/automation/types.d.ts +29 -4
  104. package/dist-sdk/src/entities/automation/types.js +76 -46
  105. package/dist-sdk/src/entities/element/build.d.ts +44 -13
  106. package/dist-sdk/src/entities/element/build.js +45 -3
  107. package/dist-sdk/src/entities/element/from-tf.d.ts +1 -1
  108. package/dist-sdk/src/entities/element/from-tf.js +28 -14
  109. package/dist-sdk/src/entities/element/index.d.ts +4 -1
  110. package/dist-sdk/src/entities/element/index.js +2 -1
  111. package/dist-sdk/src/entities/element/module.js +4 -1
  112. package/dist-sdk/src/entities/element/to-tf.js +26 -3
  113. package/dist-sdk/src/entities/field/build.d.ts +61 -14
  114. package/dist-sdk/src/entities/field/build.js +10 -0
  115. package/dist-sdk/src/entities/field/calc/runtime.js +4 -0
  116. package/dist-sdk/src/entities/field/from-tf.d.ts +5 -3
  117. package/dist-sdk/src/entities/field/from-tf.js +118 -7
  118. package/dist-sdk/src/entities/field/module.js +3 -2
  119. package/dist-sdk/src/entities/field/to-tf.d.ts +46 -11
  120. package/dist-sdk/src/entities/field/to-tf.js +166 -17
  121. package/dist-sdk/src/entities/field/types.d.ts +26 -0
  122. package/dist-sdk/src/entities/field/types.js +34 -12
  123. package/dist-sdk/src/entities/file-reader/build.d.ts +108 -50
  124. package/dist-sdk/src/entities/file-reader/build.js +23 -23
  125. package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.d.ts +6 -0
  126. package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.js +109 -0
  127. package/dist-sdk/src/entities/file-reader/from-tf.d.ts +13 -0
  128. package/dist-sdk/src/entities/file-reader/from-tf.js +172 -0
  129. package/dist-sdk/src/entities/file-reader/index.d.ts +8 -3
  130. package/dist-sdk/src/entities/file-reader/index.js +7 -2
  131. package/dist-sdk/src/entities/file-reader/module.d.ts +3 -0
  132. package/dist-sdk/src/entities/file-reader/module.js +115 -0
  133. package/dist-sdk/src/entities/file-reader/to-tf.d.ts +14 -0
  134. package/dist-sdk/src/entities/file-reader/to-tf.js +84 -0
  135. package/dist-sdk/src/entities/file-reader/types.d.ts +32 -0
  136. package/dist-sdk/src/entities/file-reader/types.js +30 -0
  137. package/dist-sdk/src/entities/org/ai-provider.d.ts +13 -0
  138. package/dist-sdk/src/entities/org/ai-provider.js +46 -0
  139. package/dist-sdk/src/entities/org/connector.d.ts +8 -1
  140. package/dist-sdk/src/entities/org/connector.js +12 -14
  141. package/dist-sdk/src/entities/org/group.js +10 -1
  142. package/dist-sdk/src/entities/org/index.d.ts +1 -0
  143. package/dist-sdk/src/entities/org/index.js +1 -0
  144. package/dist-sdk/src/entities/org/user.js +10 -1
  145. package/dist-sdk/src/entities/shared/filters/ast.d.ts +59 -9
  146. package/dist-sdk/src/entities/shared/filters/types.d.ts +1 -1
  147. package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +17 -0
  148. package/dist-sdk/src/entities/shared/tool-field-ref.js +46 -0
  149. package/dist-sdk/src/entities/shared/types/field-types.d.ts +10 -1
  150. package/dist-sdk/src/entities/shared/types/field-types.js +9 -0
  151. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +19 -0
  152. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +128 -11
  153. package/dist-sdk/src/entities/skill/from-tf.js +4 -3
  154. package/dist-sdk/src/entities/skill/index.d.ts +1 -1
  155. package/dist-sdk/src/entities/skill/module.js +7 -1
  156. package/dist-sdk/src/entities/skill/to-tf.d.ts +26 -0
  157. package/dist-sdk/src/entities/skill/to-tf.js +65 -4
  158. package/dist-sdk/src/entities/skill/tools.d.ts +37 -8
  159. package/dist-sdk/src/entities/skill/tools.js +43 -1
  160. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +34 -4
  161. package/dist-sdk/src/entities/skill-tool/from-tf.js +128 -18
  162. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +13 -1
  163. package/dist-sdk/src/entities/skill-tool/to-tf.js +164 -25
  164. package/dist-sdk/src/entities/skill-tool/types.d.ts +5 -7
  165. package/dist-sdk/src/entities/skill-tool/types.js +47 -11
  166. package/dist-sdk/src/entities/view/from-tf.d.ts +6 -2
  167. package/dist-sdk/src/entities/view/from-tf.js +11 -9
  168. package/dist-sdk/src/entities/view/to-tf.d.ts +9 -7
  169. package/dist-sdk/src/entities/view/to-tf.js +39 -18
  170. package/dist-sdk/src/entities/view/types.d.ts +1 -1
  171. package/dist-sdk/src/entities/view/types.js +1 -1
  172. package/dist-sdk/src/graph/deferred-catalog-render.d.ts +0 -5
  173. package/dist-sdk/src/graph/deferred-catalog-render.js +1 -20
  174. package/dist-sdk/src/graph/index.d.ts +8 -0
  175. package/dist-sdk/src/graph/index.js +13 -9
  176. package/dist-sdk/src/graph/modules.js +8 -1
  177. package/dist-sdk/src/graph/types.d.ts +98 -4
  178. package/package.json +49 -16
  179. package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +0 -76
  180. package/dist-sdk/src/entities/automation/value-ref-tf.js +0 -190
package/README.md CHANGED
@@ -1,409 +1,595 @@
1
1
  # @elementumai/edk
2
2
 
3
- Strongly typed TypeScript SDK and CLI for building Elementum apps, automations, agents, skills, flows, and search tables as code.
3
+ Statically typed TypeScript SDK for authoring Elementum apps, elements,
4
+ automations, agents, skills, flows, search tables, and related configuration as
5
+ code. `@elementumai/edk` is SDK-only; the standalone `elementum` CLI is
6
+ distributed separately as part of the signed toolchain.
4
7
 
5
- ## Install
8
+ This repository is the canonical source for the public SDK, the standalone
9
+ `elementum` CLI, the OpenTofu provider under `provider/`, and the temporary
10
+ private bridge under `cmd/elementum/`. The installed toolchain manages
11
+ the bridge and OpenTofu; neither is a separate public executable or checkout.
6
12
 
7
- ```bash
8
- npm install @elementumai/edk
9
- ```
13
+ ## Installation
10
14
 
11
- The SDK is a public npm package. Use Node 24.
15
+ Install the authenticated macOS or Linux x64 toolchain:
12
16
 
13
- ## Configure Auth
17
+ ```sh
18
+ curl -fsSL https://elementum-toolchain-distribution.vercel.app | sh
19
+ elementum init
20
+ ```
14
21
 
15
- Auth lives entirely in `ei` — edk holds no credentials and never talks to the
16
- platform itself. Sign in once with `ei`, and edk reads the active tenant from it:
22
+ The installer places `elementum` in `~/.elementum/bin` and adds that directory
23
+ to PATH via your shell profile (`~/.zprofile` for zsh, otherwise the applicable
24
+ profile file). The current shell won't see it until the profile reloads.
17
25
 
18
- ```bash
19
- ei auth login
20
- ```
26
+ Install the SDK in the package workspace that contains your Elementum org
27
+ folders:
21
28
 
22
- Non-interactive / CI — pick one **CLI mode** per command:
29
+ ```sh
30
+ npm install @elementumai/edk
31
+ ```
23
32
 
24
- ```bash
25
- # Ambient: current profile (auth config) + .env + shell
26
- edk plan
33
+ Use Node 24 or newer. The npm package is the authoring SDK; the only public
34
+ executable is `elementum`.
27
35
 
28
- # Explicit flags
29
- edk plan --organization <organization> --environment <environment> --instance <instance> \
30
- --client-id "$ELEMENTUM_CLIENT_ID" --client-secret "$ELEMENTUM_CLIENT_SECRET"
36
+ ### Platform support
31
37
 
32
- # Named profile
33
- edk plan --profile <profile>
38
+ The authenticated `elementum` toolchain targets macOS Apple Silicon
39
+ (`darwin-arm64`), macOS Intel (`darwin-x64`), and Linux x64
40
+ (`linux-x64`, glibc). Linux distribution work is tracked in
41
+ [#186](https://github.com/elementum-fde/edk/issues/186). The authoring SDK
42
+ (`@elementumai/edk`) remains pure TypeScript and runs anywhere Node 24+ runs.
34
43
 
35
- # Allowlisted env file for this command
36
- edk plan --profile-env-file=.env.staging
37
- ```
44
+ ## Authentication and profiles
38
45
 
39
- Auth is owned by `ei` (not edk env vars):
46
+ The SDK is credential-free and never calls the platform. Authentication and all
47
+ platform I/O are owned by the managed private bridge:
40
48
 
41
- ```bash
42
- ei auth login
43
- ei auth status
49
+ ```sh
50
+ elementum auth login --profile <profile>
51
+ elementum --profile=<profile> auth status
44
52
  ```
45
53
 
46
- edk never reads `ELEMENTUM_INSTANCE` / `ELEMENTUM_ORGANIZATION`. Workspace paths
47
- come from the folder you run in, an explicit `--root`, or
48
- `<cwd>/<instance>/<org>` from the active `ei` profile.
49
-
50
- **Before apply:** run `edk plan`. This validates that the workspace folder's
51
- instance/org matches `ei auth status`.
54
+ A profile selects the organization, instance, optional organization
55
+ environment, credentials, and custom endpoints. Pass it explicitly before any
56
+ command when reproducibility matters:
52
57
 
53
- ## Set Up An Agent Workspace
58
+ ```sh
59
+ elementum --profile=<profile> pull org --data-only
60
+ elementum --profile=<profile> plan
61
+ ```
54
62
 
55
- ```bash
56
- edk import org
57
- npx edk skills install
63
+ For `plan` and `apply`, `--profile` is optional. The CLI resolves the marked org
64
+ root from the explicit target or current directory, including targets nested
65
+ under `apps/`, `elements/`, or an individual authored file. It reads
66
+ `<instance>/<organization>` from that org root's path and selects the one saved
67
+ profile with the same identity. It does not infer tenant identity from shell
68
+ variables.
69
+
70
+ An explicit `--profile` overrides filesystem selection. The existing safety
71
+ check still rejects that profile if its instance or organization differs from
72
+ the workspace path. If no saved profile matches, or multiple profiles have the
73
+ same filesystem identity, the command fails before planning with the workspace
74
+ identity and tells you to pass `--profile` explicitly. Commands that bootstrap a
75
+ workspace should use an explicit profile because no org root exists yet.
76
+
77
+ ## Workspace setup
78
+
79
+ Start from the parent directory that will contain one or more
80
+ `<instance>/<organization>` workspaces:
81
+
82
+ ```sh
83
+ mkdir elementum-workspace
84
+ cd elementum-workspace
85
+ npm init -y
86
+ npm install @elementumai/edk
87
+ elementum auth login --profile <profile>
88
+ elementum --profile=<profile> pull org --data-only
89
+ cd <instance>/<organization>
90
+ elementum --profile=<profile> init
58
91
  ```
59
92
 
60
- `edk import org` initializes the workspace when needed, then imports org-level
61
- cloud links and AI provider connectors into the generated catalog/state. It
62
- creates:
93
+ `pull org --data-only` bootstraps and refreshes org reference identities. It
94
+ creates the package/workspace scaffolding, `org.ts`, the `@catalog` path alias,
95
+ and the Terraform input/output skeleton:
63
96
 
64
97
  ```text
65
98
  <workspace>/
66
99
  package.json
67
- .npmrc
68
100
  <instance>/
69
- <org>/
101
+ <organization>/
102
+ org.ts
103
+ tsconfig.json
104
+ backend.tf # optional locking backend; user-owned and committed
105
+ terraform.tfstate # committed local state when backend.tf is absent
70
106
  apps/
71
107
  elements/
72
- tables/
73
108
  generated/
74
109
  catalog.ts
75
- state.<env>.json
110
+ .tf/ # generated and ignored
111
+ in/ # bridge export input
112
+ out/ # SDK build output
76
113
  ```
77
114
 
78
- The org folder is always `<instance>/<org>` from active `ei auth`. It also gets
79
- a `tsconfig.json` path alias so authored files can import the generated catalog
80
- with `import catalog from "@catalog";`.
115
+ `elementum init` is an idempotent installation/workspace convergence command.
116
+ It verifies the managed compatibility train, auth, SDK namespace/version,
117
+ workspace layout, and provider identity. It never logs in or silently migrates
118
+ Terraform state.
81
119
 
82
- `edk init` is deprecated and no longer needed. Workspace initialization happens
83
- automatically as part of `edk pull org --data-only`.
120
+ Do not hand-edit `org.ts`, `generated/`, or `.tf/`. Refresh those through their
121
+ owning commands.
84
122
 
85
- Run import/pull commands from the parent workspace folder. By default they write
86
- to `<cwd>/<instance>/<org>` from `ei auth`: for example, from `edk-project`,
87
- the `edk` org on instance `dev` writes `dev/edk/generated/...` and
88
- `dev/edk/apps/...`. Plan/apply refuse a folder that doesn't match the active
89
- ei profile.
123
+ ## Recommended flow
90
124
 
91
- `edk skills install` prints the Skills CLI install command for the bundled `elementum-edk-authoring` agent skill. Pass `--yes` to run it.
125
+ Pull first when editing an object that already exists:
92
126
 
93
- ## Recommended Flow
127
+ ```sh
128
+ cd <workspace>/<instance>/<organization>
129
+ elementum --profile=<profile> pull org --data-only
130
+ elementum --profile=<profile> pull app <namespace>
131
+ # or: elementum --profile=<profile> pull element <namespace>
94
132
 
95
- For editing what already exists in Elementum, use the pull-first flow:
133
+ # edit apps/<ref>/... or elements/<ref>/...
134
+ npx tsc --noEmit
135
+ elementum build
136
+ elementum --profile=<profile> plan
137
+ elementum --profile=<profile> apply
138
+ ```
96
139
 
97
- ```bash
98
- cd <workspace>
99
- ei auth login
100
- edk pull org --data-only
101
- edk pull app <namespace>
102
- # edit the generated/authoring TypeScript
103
- edk plan
104
- edk apply
140
+ `pull app` and `pull element` reconstruct editable TypeScript, regenerate the
141
+ catalog, then automatically adopt the exported resources into the configured
142
+ Terraform state. Adoption is gated to exactly the expected imports, zero
143
+ create/update/destroy operations, and a clean follow-up plan. Use `--no-adopt`
144
+ only when you deliberately want source without state adoption.
145
+
146
+ Pull commands reserve stdout for one JSON summary. Diagnostics and stream kinds
147
+ that do not yet have an extractor are reported rather than silently discarded.
148
+
149
+ ## CLI commands
150
+
151
+ The TypeScript-owned command surface is:
152
+
153
+ ```sh
154
+ elementum init [--check] [--json]
155
+ elementum update [--check | --dry-run] [--channel stable|preview] [--version <semver>]
156
+ elementum migrate backend [orgRoot] [--check | --dry-run | --auto-approve] [--reconfigure]
157
+ elementum migrate provider-source [orgRoot] [--check | --dry-run | --auto-approve]
158
+
159
+ elementum pull org --data-only [--root <orgRoot>]
160
+ elementum pull app <namespace> [--root <orgRoot>] [--no-adopt]
161
+ elementum pull element <namespace> [--root <orgRoot>] [--no-adopt]
162
+ elementum clone app <namespace> --as <newName> [--namespace <newns>] [--root <orgRoot>]
163
+ elementum build [orgRoot]
164
+ elementum plan [orgRoot-or-nested-target] [bridge args...]
165
+ elementum apply [orgRoot-or-nested-target] [bridge args...]
166
+
167
+ elementum list apps|elements|users|groups|categories|cloud-links
168
+ elementum list ai-provider-connectors|automations|tables
169
+ elementum new app --name "Support Tickets" --namespace support --category "Operations"
170
+ elementum new element --name "Locations" --namespace locations --category "Operations"
171
+ elementum new agent --app <appRef> --name "Triage Bot"
172
+ elementum new skill --app <appRef> --name "Lookup Ticket"
173
+ elementum new automation --app <appRef> --name "Escalate Ticket"
174
+ elementum generate [path] [--root <orgRoot>]
175
+ elementum canvas <orgRoot-or-file> [--port <port>] [--no-open]
176
+ elementum playbooks list|install|status|path|print
105
177
  ```
106
178
 
107
- Run `edk pull org --data-only` before app pull workflows so org-level cloud
108
- links and AI provider connectors exist in the workspace catalog. `edk pull app`
109
- writes editable TypeScript under `<instance>/<org>/apps/<appRef>/...`;
110
- `edk plan` / `edk apply` preview and push from `.tf/out/`.
111
-
112
- ## CLI
113
-
114
- All CLI commands share one auth path: the active `ei auth` profile (`ei auth login`).
115
-
116
- ```bash
117
- edk list apps
118
- edk list users
119
- edk list groups
120
- edk list categories
121
- edk list cloud-links
122
- edk list ai-provider-connectors
123
- edk fetch app --aspect-id <uuid> --fields --agents --automations --search-tables
124
- edk import org
125
- edk import app --id <uuid>
126
- edk import element --id <uuid>
127
- edk import cloud-links
128
- edk import connectors
129
- edk import automation --id <uuid> --app-id <uuid>
130
- edk import agent --id <uuid> --app-id <uuid>
131
- edk import skill --id <uuid> --app-id <uuid>
132
- edk new agent --app <appRef> --name "Triage Bot"
133
- edk new skill --app <appRef> --name "Lookup Ticket"
134
- edk plan <instance>/<org>
135
- edk plan <instance>/<org>/apps/<appRef>
136
- edk apply <instance>/<org>
137
- edk apply <instance>/<org>/apps/<appRef>
138
- edk pull app --id <uuid> --all
139
- edk pull app --aspect-id <uuid>
140
- edk pull app --aspect-id <uuid> --all
141
- edk pull element --id <uuid>
142
- edk pull element --id <uuid> --all
143
- edk pull automation --workflow <uuid>
144
- edk pull agent --agent <uuid>
145
- edk pull skill --skill <uuid>
146
- edk pull search-table --aspect <uuid> --search-table <uuid>
147
- edk pull -i
148
- edk canvas <instance>/<org>/apps/myApp/automations/someAutomation.ts
149
- edk skills path
150
- edk skills print
179
+ `auth` and other bridge-owned commands route through the managed bridge. Run
180
+ `elementum --help` for the combined local and bridge command surface.
181
+
182
+ `build` loads app, element, and supported child authoring files and replaces its
183
+ marker-owned files under `.tf/out/`; it never calls the platform. `plan` and
184
+ `apply` run from `.tf/out/`, initialize OpenTofu there when necessary, and
185
+ forward extra arguments:
186
+
187
+ ```sh
188
+ elementum plan <instance>/<organization>/apps/myApp/myApp.ts
189
+ elementum --profile=<profile> apply <instance>/<organization> -auto-approve
151
190
  ```
152
191
 
153
- `edk import org` writes the org-level **reference-only catalog** and identity
154
- bindings for cloud links and AI provider connectors. Other `edk import ...`
155
- commands remain available as optional bootstrap/adoption tools for app or
156
- entity references; they do not write editable entity source and never put ids in
157
- source. `edk pull` writes editable EDK TypeScript under
158
- `<instance>/<org>/apps/<appRef>/...` when run from the parent workspace (plus
159
- supporting app catalog files). `--root <dir>` overrides the org workspace root
160
- for `import`.
161
- `edk pull -i` opens an interactive terminal interface for selecting entities to
162
- pull within selected application(s).
163
- `edk pull app --aspect-id <uuid> --all` pulls all entities linked to an app.
164
-
165
- `edk new agent`/`edk new skill` scaffold a new, empty agent/skill authoring
166
- file under an already-imported app's `agents/`/`skills/` folder (agents and
167
- skills are app-owned only — elements never own them). The refName is minted
168
- from `--name` and regenerates the owning app's catalog so the new entity is
169
- immediately referenceable; re-running with the same `--name` mints a
170
- disambiguated refName rather than overwriting the existing file. Run these
171
- from the parent workspace, same as `edk import`/`edk pull` — `--app` must
172
- match a refName already imported/pulled there (e.g.
173
- `<instance>/<organization>/apps/<appRef>`),
174
- so a "not imported" error usually means either the wrong `--app` value or that
175
- you ran the command from inside the org folder instead of its parent. A
176
- scaffolded agent's `connector` is left as an unresolved
177
- `catalog.connectors` placeholder — open the file and let IDE autocomplete on
178
- `catalog.connectors.` pick a real handle; it won't typecheck until you do. A
179
- scaffolded skill starts with `tools: []`, immediately compilable, plus a
180
- commented-out example call for each of the six skill tool factories
181
- (`skillSearchAspect`, `skillSearchTable`, `skillCreateRecord`,
182
- `skillUpdateRecord`, `skillAutomation`, `skillRunAgent`) with the app's own
183
- handle already filled in — uncomment whichever kinds you need, add the
184
- matching import, and autocomplete the remaining `catalog.` refs.
185
-
186
- Ignore legacy top-level files such as `generated/apps/aspects-catalog.ts`
187
- (sometimes remembered as `aspect-catalog.ts`) if you find them in an older
188
- workspace. Current catalogs live under each instance/org folder, for example
189
- `<instance>/<organization>/generated/catalog.ts` and
190
- `<instance>/<organization>/apps/<appRef>/generated/catalog.ts`.
191
-
192
- ## Canvas — explore your workspace
193
-
194
- `edk canvas` opens a local, fully offline explorer for an org workspace:
195
-
196
- ```bash
197
- edk canvas <instance>/<org> # explore a workspace directory
198
- edk canvas # same, resolved from ei auth / org workspace cwd
192
+ The optional path may be the org root or anything nested beneath it. Run from
193
+ any directory inside the marked org workspace to omit it. The CLI always runs
194
+ the bridge/OpenTofu pass-through from that root's `.tf/out/`; it does not scan
195
+ or deploy an individual target file.
196
+
197
+ `new app` and `new element` create offline org-root scaffolds — the initial
198
+ authoring file for a brand-new app or element with no existing platform
199
+ counterpart — and immediately register the new entity in the org's generated
200
+ catalog. `new agent`, `new skill`, and `new automation` create offline
201
+ app-owned scaffolds without overwriting an existing ref (automations are
202
+ app-owned only, for now). Here, `skill` means an Elementum
203
+ **agentic skill** attached to an agent.
204
+
205
+ `generate` resyncs `generated/catalog.ts` files with whatever authoring
206
+ source is currently on disk — the fix for hand-editing an existing file
207
+ (e.g. adding an automation's `onDemand` trigger parameter or an `.outputs()`
208
+ key) rather than running one of the `new`/`pull`/`clone` commands that
209
+ regenerate the catalog as a side effect of writing a brand-new file. Pass a
210
+ path to scope it to one app/element; omit it to resync the whole workspace.
211
+ It always refreshes the org-level barrel too.
212
+
213
+ Coding-agent guidance is packaged separately as
214
+ **playbooks** (Agent Skills-standard `SKILL.md` directories):
215
+
216
+ ```sh
217
+ elementum playbooks list
218
+ elementum playbooks install --yes
199
219
  ```
200
220
 
201
- The explorer opens `http://localhost:3456` and lets you navigate everything
202
- EDK manages in the workspace: apps (fields with types/flags/options, status
203
- options, the stage pipeline) and the org reference identities (cloud links,
204
- categories, connectors, groups, shown with their `org.<bag>.<key>` authoring
205
- tokens). It watches the workspace and hot-reloads on every save; `/` focuses
206
- search, which filters apps, fields, and identities live. Broken authoring
207
- files degrade to an inline error card — the rest of the workspace stays
208
- navigable.
221
+ The installed slash commands are `/elementum`, `/elementum-uat`,
222
+ `/elementum-debug`, `/elementum-deployments`, and `/elementum-design`.
223
+ `elementum skills ...` remains the platform command family for agentic-skill
224
+ operations.
225
+
226
+ ## Canvas
227
+
228
+ Canvas is an offline, live-reloading view of authored source:
229
+
230
+ ```sh
231
+ elementum canvas <instance>/<organization>
232
+ elementum canvas apps/myApp/flows/someFlow.ts
233
+ ```
209
234
 
210
- Pointing it at a **file** instead keeps the original render-tree preview:
211
- the first export with `toUI()` (or `.build().toUI()`) renders and reloads on
212
- save. Pass `--port <port>` to avoid conflicts or `--no-open` to skip opening
213
- a browser.
235
+ A directory target opens the workspace explorer at `http://localhost:3456`,
236
+ covering pulled org identities, apps, fields, status/stages, agents and their
237
+ tools, and supported automations. A file target renders the first export with
238
+ `toUI()` (or `.build().toUI()`). Use `--port <port>` to choose another port or
239
+ `--no-open` to suppress browser launch.
214
240
 
215
- ## Package Imports
241
+ ## Package imports
216
242
 
217
- Use package subpaths instead of repo-relative imports. Each entity's builder,
218
- trigger/task/tool factories, and types all live under one subpath:
243
+ Import public package subpaths, not repository-relative modules:
219
244
 
220
245
  ```ts
221
- import { defineApp, calc } from "@elementumai/edk/app";
222
- import { defineAutomation, defineWorkflow, onDemand, recordSearch } from "@elementumai/edk/automations";
223
- import { defineAgent, agentSearchAspect } from "@elementumai/edk/agents";
246
+ import { calc, defineApp } from "@elementumai/edk/app";
247
+ import { defineElement } from "@elementumai/edk/elements";
248
+ import {
249
+ defineAutomation,
250
+ defineWorkflow,
251
+ executeScript,
252
+ onDemand,
253
+ } from "@elementumai/edk/automations";
254
+ import {
255
+ agentCreateRecord,
256
+ agentRunAutomation,
257
+ agentSearchAspect,
258
+ defineAgent,
259
+ } from "@elementumai/edk/agents";
224
260
  import { defineSkill } from "@elementumai/edk/agents/skills";
225
261
  import { defineFlow } from "@elementumai/edk/flows";
226
262
  import { defineSearchTable } from "@elementumai/edk/searchTables";
227
263
  import { defineApprovalChain } from "@elementumai/edk/approvalChains";
228
264
  import { defineTable } from "@elementumai/edk/tables";
229
265
  import { eq } from "@elementumai/edk/core/filters";
266
+ import catalog from "@catalog";
230
267
  ```
231
268
 
232
- ## The Authoring Model
233
-
234
- EDK is Terraform-like. You don't paste UUIDs into source — instead:
235
-
236
- 1. `edk auth login` establishes the CLI auth profile. It can prompt
237
- interactively or accept explicit tenant/credential flags.
238
- 2. `edk import org` initializes the workspace if needed, then writes org-level
239
- reference-only catalogs/state for cloud links and AI provider connectors.
240
- Run it before pull workflows.
241
- 3. `edk pull <entity> <args>` writes editable TypeScript for live Elementum
242
- objects under `<instance>/<org>/apps/<appRef>/...` when run from the parent workspace,
243
- plus supporting catalog/state files.
244
- 4. You author against **handle-tokens** imported with
245
- `import catalog from "@catalog";` (`catalog.myApp.fields.status`,
246
- `catalog.myApp.automations.someAutomation`, `catalog.connectors.claude`). Some
247
- builders return configured `{ ref(refName), def(refName) }` objects whose
248
- refName comes from the file name; others still return `DeployableEntity` directly.
249
- There is no `.deploy()` method.
250
- 5. `edk plan <dir>` / `edk apply <dir>` regenerate app catalogs from authoring files, resolve
251
- tokens against state, diff each entity structurally against its recorded
252
- baseline, and create or update.
253
-
254
- `edk import app --id <uuid>` is still useful as an optional reference-only
255
- bootstrap/adoption path when you need app refs without pulling editable source.
256
-
257
- ## Author An Automation
258
-
259
- Start from the live app source, then author against its handle-tokens:
260
-
261
- ```bash
262
- cd <workspace>
263
- edk import org
264
- edk pull app --id <uuid> --all
265
- ```
269
+ The package exports and `typesVersions` map are kept in lockstep. Generated
270
+ source uses the same public subpaths.
271
+
272
+ ## Authoring model
273
+
274
+ EDK uses names and typed tokens in source, with the configured OpenTofu state
275
+ backend providing platform identity:
276
+
277
+ 1. `pull org --data-only` writes org reference bags to `org.ts`, including
278
+ cloud links, categories, connectors, and groups.
279
+ 2. `pull app` or `pull element` writes editable source and adopts existing
280
+ resources into the required locking remote backend.
281
+ 3. `generated/catalog.ts` is a pure barrel derived from the authored file tree.
282
+ Import app/entity tokens from `@catalog`; import org tokens from `org.ts`.
283
+ 4. `build` converts TypeScript to the one supported HCL dialect in `.tf/out/`.
284
+ 5. OpenTofu resolves references and computes create/update/replace/destroy
285
+ behavior during `plan` and `apply`.
286
+
287
+ There are no UUIDs or minted handles in authored source. The TypeScript bag key
288
+ is the Terraform label in camelCase through a lossless label conversion. For
289
+ example, a field's key in `fields: {}` is its identity; its display `name` can
290
+ change.
291
+
292
+ Configured builders such as `defineAgent` and `defineAutomation` return
293
+ `{ ref(refName), def(refName) }`. Workspace discovery supplies the ref name from
294
+ the file path. There is no `.deploy()` method.
295
+
296
+ ## Automation example
297
+
298
+ The Terraform path currently round-trips on-demand triggers plus execute-script
299
+ and create-variable tasks. Other typed trigger/task factories remain available
300
+ to the authoring API but are reported as unsupported by `build` until their
301
+ Terraform mappings land.
266
302
 
267
303
  ```ts
268
- import { defineAutomation, defineWorkflow, filter, onDemand, recordSearch } from "@elementumai/edk/automations";
269
- import catalog from "@catalog";
304
+ import { defineAutomation, onDemand } from "@elementumai/edk/automations";
305
+ import { template } from "@elementumai/edk/core";
270
306
 
271
307
  export default defineAutomation({
272
- name: "Some Automation",
273
- parent: "myApp",
274
- workflow: defineWorkflow()
275
- .trigger(onDemand({}))
276
- .task("findTickets", () => recordSearch({
277
- app: catalog.myApp,
278
- filter: filter.eq(catalog.myApp.fields.status, "Escalated"),
279
- limit: 10,
308
+ name: "Greet New Student",
309
+ parent: "students",
310
+ workflowRevision: "1.0.0",
311
+ workflow: onDemand({ STUDENT_NAME: "text" })
312
+ .setVariable("GREETING", {
313
+ value: (ctx) => template("Welcome, ", ctx.trigger.STUDENT_NAME),
314
+ })
315
+ .executeScript("FORMAT_GREETING", {
316
+ inputs: (ctx) => ({ greeting: ctx.variables.GREETING }),
317
+ code: (input) => ({
318
+ message: `${input.parameters.greeting}!`,
319
+ }),
320
+ })
321
+ .outputs((ctx) => ({
322
+ message: ctx.tasks.FORMAT_GREETING.result.message,
280
323
  })),
281
324
  });
282
325
  ```
283
326
 
284
- ## Author An Agent
327
+ The file path supplies the automation ref; `parent` is the owning app ref.
328
+ `workflowRevision` is required SemVer and is the explicit publish gate. Editing
329
+ tasks or triggers updates the draft; bump the revision only when that draft
330
+ should be published.
331
+
332
+ ## Agent example
285
333
 
286
- The AI provider connector is a `catalog.connectors.<key>` handle-token from the
287
- org catalog (`edk import org`). The builder takes options (including a
288
- `tools:` array) and returns a configured entity:
334
+ Agents live under `apps/<appRef>/agents/<agentRef>.ts`. Their connector comes
335
+ from the org catalog, while app and field targets come from `@catalog`:
289
336
 
290
337
  ```ts
291
- import { defineAgent, agentSearchAspect } from "@elementumai/edk/agents";
338
+ import { agentSearchAspect, defineAgent } from "@elementumai/edk/agents";
292
339
  import catalog from "@catalog";
340
+ import { org } from "../../../org.js";
293
341
 
294
342
  export default defineAgent({
295
343
  name: "Support Agent",
296
- parent: "myApp",
297
- connector: catalog.connectors.claude,
298
- description: "Helps with records in myApp.",
299
- instructions: "Search records and summarize next actions.",
300
- temperature: 0.2,
301
- maxLength: 2000,
344
+ parent: "support",
345
+ connector: org.connectors.claudeSonnet,
346
+ description: "Finds support records.",
347
+ instructions: "Search records and summarize the next action.",
302
348
  tools: [
303
349
  agentSearchAspect({
304
- name: "searchRecords",
305
- description: "Search myApp records.",
306
- aspect: catalog.myApp,
307
- queryDescription: "Describe the record or user request.",
350
+ name: "find_records",
351
+ description: "Searches support records.",
352
+ aspect: catalog.support,
353
+ queryDescription: "Describe the record to find.",
354
+ fields: [
355
+ {
356
+ field: catalog.support.fields.status,
357
+ description: "Current status",
358
+ },
359
+ ],
308
360
  }),
309
361
  ],
310
362
  });
311
363
  ```
312
364
 
313
- ## Plan And Apply
314
-
315
- Run the Terraform-style commands against one or more directories and/or entity
316
- files. Directory targets discover every file below that directory whose
317
- default export is a built `DeployableEntity`; file targets plan/apply only that
318
- entity. Multiple targets aggregate into one plan. Only `apply` writes:
319
-
320
- ```bash
321
- # From the parent folder that contains instance/org workspaces:
322
- edk plan <instance>/<org>
323
- edk apply <instance>/<org>
324
- edk plan <instance>/<org>/apps/myApp
325
- edk apply <instance>/<org>/apps/myApp
326
-
327
- # From inside the instance/org workspace:
328
- edk plan .
329
- edk apply .
330
- edk plan apps/myApp
331
- edk apply apps/myApp
332
-
333
- # Apply one entity in place, or several paths at once:
334
- edk plan apps/myApp/automations/someAutomation.ts
335
- edk apply elements/tag/tag.ts elements/address/address.ts
365
+ The Terraform path currently round-trips create-record, search-aspect, and
366
+ run-automation agent tools. Unsupported tools and runtime-only knobs are
367
+ reported as build diagnostics instead of being emitted as partial resources.
368
+ Authored tool names use 1–64 letters, digits, or underscores, with no doubled
369
+ underscores.
370
+
371
+ ## Plan and apply
372
+
373
+ Always build before planning:
374
+
375
+ ```sh
376
+ cd <workspace>/<instance>/<organization>
377
+ elementum build
378
+ elementum plan
379
+ elementum apply
380
+ ```
381
+
382
+ `plan` and `apply` are pass-throughs to the managed bridge with inherited
383
+ stdio. With no explicit profile, the CLI selects the unique saved profile
384
+ matching the org root's `<instance>/<organization>` path. Review destroy and
385
+ replacement actions just as you would in any Terraform plan.
386
+
387
+ ## Identity and state recovery
388
+
389
+ Terraform state is the durable binding between authored labels and live
390
+ platform objects. For backwards compatibility, a workspace without
391
+ `<orgRoot>/backend.tf` continues to use the committed root
392
+ `terraform.tfstate` through a generated local backend. This preserves existing
393
+ single-author workspaces, but it provides no state locking; avoid concurrent
394
+ plan/apply operations in that mode.
395
+
396
+ Shared workspaces and CI should commit one user-owned, non-secret
397
+ `<orgRoot>/backend.tf` containing a complete
398
+ `terraform { backend "TYPE" { ... } }` declaration with verified locking.
399
+ `elementum build` projects either that declaration or the compatibility local
400
+ backend into `.tf/out/backend.tf`. Never commit `.terraform/`, `.tf/`, backend
401
+ credential files, or saved plan files. After migrating to remote state, remove
402
+ and stop committing the root `terraform.tfstate`.
403
+
404
+ For example, an S3 backend with native locking can be declared as:
405
+
406
+ ```hcl
407
+ terraform {
408
+ backend "s3" {
409
+ bucket = "elementum-team-state"
410
+ key = "prod/acme/terraform.tfstate"
411
+ region = "us-east-1"
412
+ dynamodb_table = "elementum-state-locks"
413
+ encrypt = true
414
+ }
415
+ }
416
+ ```
417
+
418
+ The backend body remains native OpenTofu HCL, but EDK validates the locking
419
+ contract. Native-locking backends `azurerm`, `cos`, `gcs`, `kubernetes`, `pg`,
420
+ and `remote` are accepted. `consul` must omit `lock` (the default is true) or
421
+ set `lock = true`. `s3` must set `use_lockfile = true` or `dynamodb_table`;
422
+ `http` must set both
423
+ `lock_address` and `unlock_address`; `oss` must set both
424
+ `tablestore_endpoint` and `tablestore_table`. Optional-backend lock settings
425
+ must be literal so EDK can verify them before state access. An explicitly
426
+ authored `local` backend, unlocked/unknown backends, and configurations EDK
427
+ cannot verify fail closed; the generated local compatibility backend is the
428
+ only local exception.
429
+ The storage and locking infrastructure and access policies must already exist;
430
+ EDK does not provision them.
431
+
432
+ Backend authentication must use that backend's standard environment or
433
+ workload-identity chain: for example AWS/GCP/Azure OIDC, an IAM role, or
434
+ environment variables supplied by CI. Do not put access keys, passwords,
435
+ tokens, secret-manager data sources, or credential paths in `backend.tf`.
436
+ Backend initialization happens before providers and data sources, so it cannot
437
+ read a Terraform-managed secret. EDK does not accept `-backend-config` secrets
438
+ and never writes backend credentials into generated HCL.
439
+
440
+ OpenTofu owns locking. EDK does not implement a weaker parallel lock or disable
441
+ native locking: `plan`, `apply`, adoption imports, rename `state mv`, and
442
+ state-repair operations use the declared backend. Standard options such as
443
+ `-lock-timeout=5m` pass through:
444
+
445
+ ```sh
446
+ elementum --profile=<profile> plan <orgRoot> -lock-timeout=5m
447
+ elementum --profile=<profile> apply <orgRoot> -auto-approve -lock-timeout=5m
448
+ ```
449
+
450
+ Backend initialization is lazy and noninteractive. A per-working-directory
451
+ fingerprint prevents ordinary plan/apply/state commands from silently
452
+ re-binding a changed backend; use the guarded migration command instead.
453
+
454
+ ### Migrate committed local state to a remote backend
455
+
456
+ Create the backend infrastructure first, then add and review `backend.tf`.
457
+ The migration uses native `tofu init -migrate-state`, takes an ignored recovery
458
+ snapshot, refuses to overwrite unrelated destination state, verifies
459
+ lineage/resources, removes the obsolete root copy, and requires a final
460
+ zero-change plan:
461
+
462
+ ```sh
463
+ elementum migrate backend <orgRoot> --check
464
+ elementum migrate backend <orgRoot> --dry-run
465
+ elementum migrate backend <orgRoot> --auto-approve
466
+ elementum --profile=<profile> plan <orgRoot>
467
+ ```
468
+
469
+ For a remote-to-remote change, edit `backend.tf` and run the same migration.
470
+ Use `--reconfigure` only to bind an already-populated destination without
471
+ copying the currently bound state. It is rejected while local committed state
472
+ still exists.
473
+
474
+ Recovery snapshots and exact rollback commands are printed on failure and kept
475
+ under `.tf/migration-backups/backend/`. The command updates `.gitignore` but
476
+ does not rewrite Git history or mutate the index. After a successful
477
+ local-to-remote migration, commit the root-state deletion with `backend.tf` and
478
+ `.gitignore`; review the diff before pushing:
479
+
480
+ ```sh
481
+ git add backend.tf .gitignore
482
+ git add -u terraform.tfstate
483
+ git commit
484
+ ```
485
+
486
+ If state is lost, do not apply the built configuration: OpenTofu would see the
487
+ live objects as new. Restore/push the recovery snapshot or re-adopt each stream
488
+ with:
489
+
490
+ ```sh
491
+ elementum --profile=<profile> pull org --data-only
492
+ elementum --profile=<profile> pull app <namespace>
493
+ elementum --profile=<profile> pull element <namespace>
494
+ ```
495
+
496
+ After an update reports an old provider identity, inspect and explicitly
497
+ migrate the configured state:
498
+
499
+ ```sh
500
+ elementum migrate provider-source <orgRoot> --check
501
+ elementum migrate provider-source <orgRoot> --auto-approve
502
+ elementum --profile=<profile> plan <orgRoot>
503
+ ```
504
+
505
+ The migration reads the configured local or remote state, creates an ignored
506
+ recovery snapshot, runs backend-bound OpenTofu `state replace-provider`,
507
+ refreshes generated provider configuration, and never applies infrastructure.
508
+
509
+ ### CI/CD
510
+
511
+ Use a serialized protected deployment job and let the backend lock arbitrate
512
+ all writers. Supply Elementum auth through the bridge's CI profile setup and
513
+ backend auth through workload identity/environment variables. A current
514
+ GitHub Actions job (the public signed toolchain is macOS-only today) looks like:
515
+
516
+ ```yaml
517
+ jobs:
518
+ apply:
519
+ runs-on: macos-14
520
+ concurrency:
521
+ group: elementum-prod
522
+ cancel-in-progress: false
523
+ permissions:
524
+ contents: read
525
+ id-token: write
526
+ steps:
527
+ - uses: actions/checkout@v4
528
+ - run: npm ci
529
+ - run: elementum build ./us/acme
530
+ - run: elementum --profile=ci plan ./us/acme -lock-timeout=5m
531
+ - run: elementum --profile=ci apply ./us/acme -auto-approve -lock-timeout=5m
336
532
  ```
337
533
 
338
- `apply` prints the same plan first, then asks for confirmation. Only typing
339
- `yes` applies creates and updates. If no target is supplied, the command
340
- uses the current working directory. Files starting with `_` and
341
- test/declaration files are ignored, so private helper scripts are not
342
- imported.
343
-
344
- Every target must live under an org workspace whose folder matches the active
345
- auth org — either a bare `<org>/...` or the nested `<instance>/<org>/...`
346
- (for example `eu/sanofi/elements/foo.ts`). When the org folder sits directly
347
- under a recognized instance name (`us`, `eu`, `stage`, `dev`, `local`), that
348
- instance segment must also match the active auth config. Authoring files
349
- inside must additionally sit under `apps/<ref>/` or `elements/<ref>/` in one of
350
- the accepted shapes (the aspect file itself, or a child bag like
351
- `automations/<name>.ts`) — a flat `apps/<name>.ts` is rejected.
352
-
353
- Plan output uses the recorded `generated/state.<env>.json` bindings and reports
354
- create, update, skip, blocked, disabled, and update-unsupported verdicts.
355
-
356
- Builds are local. `plan`/`apply` require an active `ei auth` profile matching the workspace folder.
357
-
358
- ## Create Vs Update
359
-
360
- `plan`/`apply` resolve each entity's handle-tokens against `generated/state.<env>.json`, then
361
- decide per entity:
362
-
363
- - **create** — no binding recorded for this `kind::refName` → POST.
364
- - **skip** — bound, and a structural diff against the recorded baseline is
365
- empty → no wire call.
366
- - **update** — bound, and the payload differs → PUT against the bound id,
367
- carrying the changed fields. (A bound-but-baseline-less entity — e.g. one
368
- imported reference-only and now being managed — diffs as all-changed and
369
- reconciles the platform to local source.)
370
- - **update-unsupported** — bound and changed, but the kind has no platform
371
- PUT. Apply reports `DeployUpdateUnsupportedError`; delete the entity on the
372
- platform and re-create.
373
- - **blocked** — a referenced handle isn't bound yet (import the app/entity it
374
- points at). Apply surfaces the miss rather than POSTing a dangling reference.
375
-
376
- Support today:
377
-
378
- - **Automations, agents, skills** support create, update, and skip.
379
- - **Flows, search tables, tables** are create-only — a change to a deployed one
380
- is `update-unsupported` until the platform ships PUT.
381
-
382
- There are no source-level ids and no `.deploy()` seed refs anymore: identity
383
- lives entirely in state. On disk, state is consolidated into
384
- `generated/state.<env>.json` in the org workspace; it contains org bindings,
385
- the app registry, per-app bindings, and baselines. Override the generated-state
386
- directory with `EDK_STATE_DIR`. Commit the state file to share identity across
387
- machines; gitignore it for per-developer state.
388
-
389
- If a state file is corrupt or schema-incompatible, the loader throws
390
- `DeployStateCorruptError` rather than silently rebuilding it — re-import the
391
- owning app to rebuild bindings.
392
-
393
- ### Recovering identity
394
-
395
- Lost `generated/state.<env>.json` (fresh clone, deleted by accident) means EDK no longer knows
396
- which platform entities your handle-tokens map to. Re-run `edk import org` for
397
- org references, then pull the app/entity again or use `edk import app --id
398
- <uuid>` as a reference-only bootstrap when you only need bindings. Author files
399
- keep working unchanged because they only reference handles, never ids.
534
+ The command sequence and environment contract are identical on a noninteractive
535
+ Linux runner when your organization supplies the Linux toolchain artifact;
536
+ the public installer does not yet distribute Linux binaries.
537
+
538
+ ## Create and update semantics
539
+
540
+ Terraform owns lifecycle decisions; EDK has no second deployment state machine:
541
+
542
+ - Configured resource absent from state: create.
543
+ - Resource present in config and state with changed attributes: update in place
544
+ or replace, according to provider schema.
545
+ - Resource present in state but absent from built config: destroy.
546
+ - Existing platform resource mapped into state by pull: adopt.
547
+
548
+ Pull adoption's zero-write gates prevent an existing resource from being
549
+ mistaken for a create. Build diagnostics are part of the safety contract:
550
+ unsupported stream kinds are never silently adopted or emitted. Renames that
551
+ change an exported Terraform label are guarded during adoption and rebound with
552
+ state moves when the existing platform identity can be proven.
400
553
 
401
554
  ## Development
402
555
 
403
- ```bash
404
- npm install
405
- npm run build
406
- npm run typecheck
407
- npm test
408
- npm run pack:dry-run
556
+ The repository builds three distinct output trees:
557
+
558
+ - `dist-sdk/` — `tsc -p tsconfig.sdk.json` output, the sole source tree packed
559
+ into the `@elementumai/edk` SDK package;
560
+ - `dist-cli/` — Node-compatible `tsc -p tsconfig.cli.json` output used by local
561
+ development, tests, integration tooling, and the binary build script; it is
562
+ not part of the SDK package or the final release payload;
563
+ - `dist-bin/` — standalone `elementum` executables produced from `dist-cli` by
564
+ the locked local Bun dependency; these are the CLI release inputs distributed
565
+ separately from npm.
566
+
567
+ The repository's principal source roots are siblings:
568
+
569
+ ```text
570
+ src/ # TypeScript SDK and public CLI
571
+ cmd/elementum/ # temporary private Go bridge module
572
+ provider/ # OpenTofu provider module
573
+ distribution/ # registry and installer package
574
+ ```
575
+
576
+ Contributor setup, change-specific tests, Go/provider checks, and pull-request
577
+ verification are documented in [CONTRIBUTING.md](CONTRIBUTING.md). The shortest
578
+ local CLI path is:
579
+
580
+ ```sh
581
+ npm run local:setup
582
+ npm run elementum -- --help
583
+ npm run test:cli
409
584
  ```
585
+
586
+ See [binary validation](docs/edk-binary.md) for release and
587
+ compatibility-train checks.
588
+
589
+ ## Contributor integration harness
590
+
591
+ The Preston High harness creates, mutates, renames, and deletes live resources.
592
+ Use only a dedicated test organization and profile. The complete setup,
593
+ required org identities, golden-workspace flow, command flags, and failure
594
+ semantics live in the
595
+ [Golden integration test](CONTRIBUTING.md#golden-integration-test).