@elevasis/sdk 0.4.5 → 0.4.7

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 (40) hide show
  1. package/dist/cli.cjs +829 -413
  2. package/dist/index.d.ts +79 -14
  3. package/dist/index.js +17 -12
  4. package/dist/templates.js +747 -0
  5. package/dist/types/templates.d.ts +1 -0
  6. package/dist/types/worker/index.d.ts +6 -0
  7. package/dist/types/worker/platform.d.ts +32 -0
  8. package/dist/worker/index.js +4701 -9
  9. package/package.json +10 -3
  10. package/reference/_index.md +95 -0
  11. package/reference/_navigation.md +104 -0
  12. package/reference/cli/index.mdx +497 -0
  13. package/reference/concepts/index.mdx +203 -0
  14. package/reference/deployment/api.mdx +297 -0
  15. package/reference/deployment/index.mdx +153 -0
  16. package/reference/developer/interaction-guidance.mdx +213 -0
  17. package/reference/framework/agent.mdx +175 -0
  18. package/reference/framework/documentation.mdx +92 -0
  19. package/reference/framework/index.mdx +95 -0
  20. package/reference/framework/memory.mdx +337 -0
  21. package/reference/framework/project-structure.mdx +294 -0
  22. package/reference/getting-started/index.mdx +148 -0
  23. package/reference/index.mdx +113 -0
  24. package/reference/platform-tools/examples.mdx +187 -0
  25. package/reference/platform-tools/index.mdx +182 -0
  26. package/reference/resources/index.mdx +289 -0
  27. package/reference/resources/patterns.mdx +341 -0
  28. package/reference/resources/types.mdx +207 -0
  29. package/reference/roadmap/index.mdx +147 -0
  30. package/reference/runtime/index.mdx +141 -0
  31. package/reference/runtime/limits.mdx +77 -0
  32. package/reference/security/credentials.mdx +141 -0
  33. package/reference/templates/data-enrichment.mdx +162 -0
  34. package/reference/templates/email-sender.mdx +135 -0
  35. package/reference/templates/lead-scorer.mdx +175 -0
  36. package/reference/templates/pdf-generator.mdx +151 -0
  37. package/reference/templates/recurring-job.mdx +189 -0
  38. package/reference/templates/text-classifier.mdx +147 -0
  39. package/reference/templates/web-scraper.mdx +135 -0
  40. package/reference/troubleshooting/common-errors.mdx +210 -0
package/dist/cli.cjs CHANGED
@@ -6622,14 +6622,14 @@ var require_async_iterator = __commonJS({
6622
6622
  };
6623
6623
  }
6624
6624
  function readAndResolve(iter) {
6625
- var resolve5 = iter[kLastResolve];
6626
- if (resolve5 !== null) {
6625
+ var resolve6 = iter[kLastResolve];
6626
+ if (resolve6 !== null) {
6627
6627
  var data = iter[kStream].read();
6628
6628
  if (data !== null) {
6629
6629
  iter[kLastPromise] = null;
6630
6630
  iter[kLastResolve] = null;
6631
6631
  iter[kLastReject] = null;
6632
- resolve5(createIterResult(data, false));
6632
+ resolve6(createIterResult(data, false));
6633
6633
  }
6634
6634
  }
6635
6635
  }
@@ -6637,13 +6637,13 @@ var require_async_iterator = __commonJS({
6637
6637
  process.nextTick(readAndResolve, iter);
6638
6638
  }
6639
6639
  function wrapForNext(lastPromise, iter) {
6640
- return function(resolve5, reject) {
6640
+ return function(resolve6, reject) {
6641
6641
  lastPromise.then(function() {
6642
6642
  if (iter[kEnded]) {
6643
- resolve5(createIterResult(void 0, true));
6643
+ resolve6(createIterResult(void 0, true));
6644
6644
  return;
6645
6645
  }
6646
- iter[kHandlePromise](resolve5, reject);
6646
+ iter[kHandlePromise](resolve6, reject);
6647
6647
  }, reject);
6648
6648
  };
6649
6649
  }
@@ -6663,12 +6663,12 @@ var require_async_iterator = __commonJS({
6663
6663
  return Promise.resolve(createIterResult(void 0, true));
6664
6664
  }
6665
6665
  if (this[kStream].destroyed) {
6666
- return new Promise(function(resolve5, reject) {
6666
+ return new Promise(function(resolve6, reject) {
6667
6667
  process.nextTick(function() {
6668
6668
  if (_this[kError]) {
6669
6669
  reject(_this[kError]);
6670
6670
  } else {
6671
- resolve5(createIterResult(void 0, true));
6671
+ resolve6(createIterResult(void 0, true));
6672
6672
  }
6673
6673
  });
6674
6674
  });
@@ -6691,13 +6691,13 @@ var require_async_iterator = __commonJS({
6691
6691
  return this;
6692
6692
  }), _defineProperty(_Object$setPrototypeO, "return", function _return() {
6693
6693
  var _this2 = this;
6694
- return new Promise(function(resolve5, reject) {
6694
+ return new Promise(function(resolve6, reject) {
6695
6695
  _this2[kStream].destroy(null, function(err) {
6696
6696
  if (err) {
6697
6697
  reject(err);
6698
6698
  return;
6699
6699
  }
6700
- resolve5(createIterResult(void 0, true));
6700
+ resolve6(createIterResult(void 0, true));
6701
6701
  });
6702
6702
  });
6703
6703
  }), _Object$setPrototypeO), AsyncIteratorPrototype);
@@ -6719,15 +6719,15 @@ var require_async_iterator = __commonJS({
6719
6719
  value: stream._readableState.endEmitted,
6720
6720
  writable: true
6721
6721
  }), _defineProperty(_Object$create, kHandlePromise, {
6722
- value: function value(resolve5, reject) {
6722
+ value: function value(resolve6, reject) {
6723
6723
  var data = iterator[kStream].read();
6724
6724
  if (data) {
6725
6725
  iterator[kLastPromise] = null;
6726
6726
  iterator[kLastResolve] = null;
6727
6727
  iterator[kLastReject] = null;
6728
- resolve5(createIterResult(data, false));
6728
+ resolve6(createIterResult(data, false));
6729
6729
  } else {
6730
- iterator[kLastResolve] = resolve5;
6730
+ iterator[kLastResolve] = resolve6;
6731
6731
  iterator[kLastReject] = reject;
6732
6732
  }
6733
6733
  },
@@ -6746,12 +6746,12 @@ var require_async_iterator = __commonJS({
6746
6746
  iterator[kError] = err;
6747
6747
  return;
6748
6748
  }
6749
- var resolve5 = iterator[kLastResolve];
6750
- if (resolve5 !== null) {
6749
+ var resolve6 = iterator[kLastResolve];
6750
+ if (resolve6 !== null) {
6751
6751
  iterator[kLastPromise] = null;
6752
6752
  iterator[kLastResolve] = null;
6753
6753
  iterator[kLastReject] = null;
6754
- resolve5(createIterResult(void 0, true));
6754
+ resolve6(createIterResult(void 0, true));
6755
6755
  }
6756
6756
  iterator[kEnded] = true;
6757
6757
  });
@@ -6766,7 +6766,7 @@ var require_async_iterator = __commonJS({
6766
6766
  var require_from = __commonJS({
6767
6767
  "../../node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/from.js"(exports2, module2) {
6768
6768
  "use strict";
6769
- function asyncGeneratorStep(gen, resolve5, reject, _next, _throw, key, arg) {
6769
+ function asyncGeneratorStep(gen, resolve6, reject, _next, _throw, key, arg) {
6770
6770
  try {
6771
6771
  var info = gen[key](arg);
6772
6772
  var value = info.value;
@@ -6775,7 +6775,7 @@ var require_from = __commonJS({
6775
6775
  return;
6776
6776
  }
6777
6777
  if (info.done) {
6778
- resolve5(value);
6778
+ resolve6(value);
6779
6779
  } else {
6780
6780
  Promise.resolve(value).then(_next, _throw);
6781
6781
  }
@@ -6783,13 +6783,13 @@ var require_from = __commonJS({
6783
6783
  function _asyncToGenerator(fn) {
6784
6784
  return function() {
6785
6785
  var self2 = this, args = arguments;
6786
- return new Promise(function(resolve5, reject) {
6786
+ return new Promise(function(resolve6, reject) {
6787
6787
  var gen = fn.apply(self2, args);
6788
6788
  function _next(value) {
6789
- asyncGeneratorStep(gen, resolve5, reject, _next, _throw, "next", value);
6789
+ asyncGeneratorStep(gen, resolve6, reject, _next, _throw, "next", value);
6790
6790
  }
6791
6791
  function _throw(err) {
6792
- asyncGeneratorStep(gen, resolve5, reject, _next, _throw, "throw", err);
6792
+ asyncGeneratorStep(gen, resolve6, reject, _next, _throw, "throw", err);
6793
6793
  }
6794
6794
  _next(void 0);
6795
6795
  });
@@ -26489,7 +26489,7 @@ var require_gray_matter = __commonJS({
26489
26489
 
26490
26490
  // src/cli/index.ts
26491
26491
  var import_dotenv = __toESM(require_main(), 1);
26492
- var import_path4 = require("path");
26492
+ var import_path5 = require("path");
26493
26493
 
26494
26494
  // ../../node_modules/.pnpm/commander@11.1.0/node_modules/commander/esm.mjs
26495
26495
  var import_index = __toESM(require_commander(), 1);
@@ -40224,7 +40224,7 @@ var GPT5OptionsSchema = external_exports.object({
40224
40224
  var GPT5ConfigSchema = external_exports.object({
40225
40225
  model: external_exports.enum(["gpt-5", "gpt-5-mini"]),
40226
40226
  provider: external_exports.enum(["openai"]),
40227
- apiKey: external_exports.string().min(1),
40227
+ apiKey: external_exports.string(),
40228
40228
  temperature: external_exports.literal(1),
40229
40229
  // Required to be exactly 1
40230
40230
  maxTokens: external_exports.number().min(4e3).optional(),
@@ -40254,7 +40254,7 @@ var OpenRouterConfigSchema = external_exports.object({
40254
40254
  "openrouter/x-ai/grok-4.1-fast"
40255
40255
  ]),
40256
40256
  provider: external_exports.literal("openrouter"),
40257
- apiKey: external_exports.string().min(1),
40257
+ apiKey: external_exports.string(),
40258
40258
  temperature: external_exports.number().min(0).max(2).optional(),
40259
40259
  maxTokens: external_exports.number().min(500).optional(),
40260
40260
  topP: external_exports.number().min(0).max(1).optional(),
@@ -40267,7 +40267,7 @@ var GoogleOptionsSchema = external_exports.object({
40267
40267
  var GoogleConfigSchema = external_exports.object({
40268
40268
  model: external_exports.enum(["gemini-3-flash-preview"]),
40269
40269
  provider: external_exports.literal("google"),
40270
- apiKey: external_exports.string().min(1),
40270
+ apiKey: external_exports.string(),
40271
40271
  temperature: external_exports.literal(1).optional(),
40272
40272
  // Must be 1 for Gemini 3 (changing degrades performance)
40273
40273
  maxTokens: external_exports.number().min(500).optional(),
@@ -40278,7 +40278,7 @@ var AnthropicOptionsSchema = external_exports.object({});
40278
40278
  var AnthropicConfigSchema = external_exports.object({
40279
40279
  model: external_exports.enum(["claude-opus-4-5", "claude-sonnet-4-5", "claude-haiku-4-5"]),
40280
40280
  provider: external_exports.literal("anthropic"),
40281
- apiKey: external_exports.string().min(1),
40281
+ apiKey: external_exports.string(),
40282
40282
  temperature: external_exports.number().min(0).max(1).optional(),
40283
40283
  maxTokens: external_exports.number().min(1e3).optional(),
40284
40284
  // Anthropic requires max_tokens
@@ -42868,6 +42868,12 @@ var zodToJsonSchema = (schema, options2) => {
42868
42868
  return combined;
42869
42869
  };
42870
42870
 
42871
+ // ../core/src/execution/engine/workflow/types.ts
42872
+ var StepType = {
42873
+ LINEAR: "linear",
42874
+ CONDITIONAL: "conditional"
42875
+ };
42876
+
42871
42877
  // ../core/src/execution/engine/base/serialization.ts
42872
42878
  function serializeDefinition(definition, options2) {
42873
42879
  const opts = {
@@ -42952,13 +42958,13 @@ function serializeKnowledgeMap(km, ctx) {
42952
42958
  }
42953
42959
  function serializeNextConfig(nextConfig, _context) {
42954
42960
  if (!nextConfig) return null;
42955
- if (nextConfig.type === "linear" /* LINEAR */) {
42961
+ if (nextConfig.type === StepType.LINEAR) {
42956
42962
  return {
42957
42963
  type: nextConfig.type,
42958
42964
  target: nextConfig.target
42959
42965
  };
42960
42966
  }
42961
- if (nextConfig.type === "conditional" /* CONDITIONAL */) {
42967
+ if (nextConfig.type === StepType.CONDITIONAL) {
42962
42968
  return {
42963
42969
  type: nextConfig.type,
42964
42970
  routes: nextConfig.routes?.map((route) => ({
@@ -43010,7 +43016,7 @@ function isKnowledgeMapObject(value) {
43010
43016
  return value && typeof value === "object" && "nodes" in value && typeof value.nodes === "object";
43011
43017
  }
43012
43018
  function isNextConfigObject(value) {
43013
- return value && typeof value === "object" && "type" in value && (value.type === "linear" /* LINEAR */ || value.type === "conditional" /* CONDITIONAL */);
43019
+ return value && typeof value === "object" && "type" in value && (value.type === StepType.LINEAR || value.type === StepType.CONDITIONAL);
43014
43020
  }
43015
43021
  function isSecretKey(key) {
43016
43022
  const lower = key.toLowerCase();
@@ -43774,41 +43780,9 @@ async function apiPost(endpoint, body, apiUrl = resolveApiUrl()) {
43774
43780
  }
43775
43781
  return response.json();
43776
43782
  }
43777
- async function apiPut(endpoint, body, apiUrl = resolveApiUrl()) {
43778
- const response = await fetch(`${apiUrl}${endpoint}`, {
43779
- method: "PUT",
43780
- headers: {
43781
- Authorization: `Bearer ${getApiKey()}`,
43782
- "Content-Type": "application/json"
43783
- },
43784
- body: JSON.stringify(body)
43785
- });
43786
- if (!response.ok) {
43787
- const errorText = await response.text();
43788
- throw new Error(`API request failed (${response.status}): ${errorText}`);
43789
- }
43790
- if (response.status === 204) {
43791
- return {};
43792
- }
43793
- return response.json();
43794
- }
43795
- async function apiDelete(endpoint, apiUrl = resolveApiUrl()) {
43796
- const response = await fetch(`${apiUrl}${endpoint}`, {
43797
- method: "DELETE",
43798
- headers: { Authorization: `Bearer ${getApiKey()}` }
43799
- });
43800
- if (!response.ok) {
43801
- const errorText = await response.text();
43802
- throw new Error(`API request failed (${response.status}): ${errorText}`);
43803
- }
43804
- if (response.status === 204) {
43805
- return {};
43806
- }
43807
- return response.json();
43808
- }
43809
43783
 
43810
43784
  // src/cli/version.ts
43811
- var SDK_VERSION = "0.4.5";
43785
+ var SDK_VERSION = "0.4.6";
43812
43786
 
43813
43787
  // src/cli/commands/deploy.ts
43814
43788
  var import_meta2 = {};
@@ -44459,27 +44433,37 @@ function registerDescribeCommand(program3) {
44459
44433
  // src/cli/commands/init.ts
44460
44434
  var import_path3 = require("path");
44461
44435
  var import_promises2 = require("fs/promises");
44462
- var SCAFFOLD_FILES = [
44463
- "elevasis.config.ts",
44436
+ var TEMPLATE_VERSION = 4;
44437
+ var INIT_ONLY_FILES = [
44464
44438
  "package.json",
44465
44439
  "pnpm-workspace.yaml",
44466
44440
  "tsconfig.json",
44467
44441
  ".env",
44468
44442
  ".env.example",
44469
44443
  ".npmrc",
44470
- ".gitignore",
44471
44444
  "src/index.ts",
44445
+ "src/workflows/echo.ts",
44472
44446
  "docs/index.mdx",
44447
+ "docs/in-progress/.gitkeep"
44448
+ ];
44449
+ var MANAGED_FILES = [
44450
+ "elevasis.config.ts",
44451
+ ".gitignore",
44473
44452
  "CLAUDE.md",
44474
44453
  ".claude/settings.json",
44475
44454
  ".claude/commands/docs.md",
44476
44455
  ".claude/commands/resource.md",
44477
- ".claude/commands/deploy.md",
44478
- ".claude/commands/inspect.md",
44479
- ".claude/commands/env.md"
44456
+ ".claude/commands/tutorial.md",
44457
+ ".claude/commands/help.md",
44458
+ ".claude/commands/templates.md",
44459
+ ".claude/commands/database.md",
44460
+ ".claude/commands/agent.md",
44461
+ ".claude/commands/profile.md",
44462
+ ".claude/commands/meta.md"
44480
44463
  ];
44464
+ var SCAFFOLD_FILES = [...INIT_ONLY_FILES, ...MANAGED_FILES];
44481
44465
  function registerInitCommand(program3) {
44482
- program3.command("init [directory]").description("Scaffold a new Elevasis project\n Example: elevasis init my-project").option("--force", "Overwrite existing files").action(wrapAction("init", async (directory, options2) => {
44466
+ program3.command("init [directory]").description("Scaffold a new Elevasis workspace\n Example: elevasis init my-workspace").option("--force", "Overwrite existing files").action(wrapAction("init", async (directory, options2) => {
44483
44467
  const targetDir = directory ? (0, import_path3.resolve)(directory) : process.cwd();
44484
44468
  const orgSlug = toSlug((0, import_path3.basename)(targetDir));
44485
44469
  if (!options2.force) {
@@ -44500,8 +44484,8 @@ function registerInitCommand(program3) {
44500
44484
  throw new Error("Scaffold conflict");
44501
44485
  }
44502
44486
  }
44503
- await (0, import_promises2.mkdir)((0, import_path3.resolve)(targetDir, "src"), { recursive: true });
44504
- await (0, import_promises2.mkdir)((0, import_path3.resolve)(targetDir, "docs"), { recursive: true });
44487
+ await (0, import_promises2.mkdir)((0, import_path3.resolve)(targetDir, "src/workflows"), { recursive: true });
44488
+ await (0, import_promises2.mkdir)((0, import_path3.resolve)(targetDir, "docs/in-progress"), { recursive: true });
44505
44489
  await (0, import_promises2.mkdir)((0, import_path3.resolve)(targetDir, ".claude/commands"), { recursive: true });
44506
44490
  const files = {
44507
44491
  "elevasis.config.ts": configTemplate(),
@@ -44513,19 +44497,25 @@ function registerInitCommand(program3) {
44513
44497
  ".npmrc": npmrcTemplate(),
44514
44498
  ".gitignore": gitignoreTemplate(),
44515
44499
  "src/index.ts": starterTemplate(),
44500
+ "src/workflows/echo.ts": starterWorkflowTemplate(),
44516
44501
  "docs/index.mdx": docsIndexTemplate(orgSlug),
44502
+ "docs/in-progress/.gitkeep": "",
44517
44503
  "CLAUDE.md": claudeMdTemplate(),
44518
44504
  ".claude/settings.json": claudeSettingsTemplate(),
44519
44505
  ".claude/commands/docs.md": claudeDocsCommandTemplate(),
44520
44506
  ".claude/commands/resource.md": claudeResourceCommandTemplate(),
44521
- ".claude/commands/deploy.md": claudeDeployCommandTemplate(),
44522
- ".claude/commands/inspect.md": claudeInspectCommandTemplate(),
44523
- ".claude/commands/env.md": claudeEnvCommandTemplate()
44507
+ ".claude/commands/tutorial.md": claudeTutorialCommandTemplate(),
44508
+ ".claude/commands/help.md": claudeHelpCommandTemplate(),
44509
+ ".claude/commands/templates.md": claudeTemplatesCommandTemplate(),
44510
+ ".claude/commands/database.md": claudeDatabaseCommandTemplate(),
44511
+ ".claude/commands/agent.md": claudeAgentCommandTemplate(),
44512
+ ".claude/commands/profile.md": claudeProfileCommandTemplate(),
44513
+ ".claude/commands/meta.md": claudeMetaCommandTemplate()
44524
44514
  };
44525
44515
  for (const [filePath, content] of Object.entries(files)) {
44526
44516
  await (0, import_promises2.writeFile)((0, import_path3.resolve)(targetDir, filePath), content, "utf-8");
44527
44517
  }
44528
- console.log(source_default.green.bold(" Project created!"));
44518
+ console.log(source_default.green.bold(" Workspace created!"));
44529
44519
  console.log("");
44530
44520
  console.log(source_default.gray(" Next steps:"));
44531
44521
  if (directory) {
@@ -44539,12 +44529,13 @@ function registerInitCommand(program3) {
44539
44529
  }
44540
44530
  function toSlug(name) {
44541
44531
  const slug = name.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/^[^a-z]+/, "").replace(/-+/g, "-").replace(/-$/, "");
44542
- return slug.length >= 3 ? slug : "my-project";
44532
+ return slug.length >= 3 ? slug : "my-workspace";
44543
44533
  }
44544
44534
  function configTemplate() {
44545
44535
  return `import type { ElevasConfig } from '@elevasis/sdk'
44546
44536
 
44547
44537
  export default {
44538
+ templateVersion: ${TEMPLATE_VERSION},
44548
44539
  // defaultStatus: 'dev', // Default status for new resources ('dev' | 'production')
44549
44540
  // dev: { port: 5170 }, // Local API port (internal development only)
44550
44541
  } satisfies ElevasConfig
@@ -44607,19 +44598,19 @@ function gitignoreTemplate() {
44607
44598
  dist/
44608
44599
  __elevasis_worker.ts
44609
44600
  .claude/settings.local.json
44610
- .claude/profile.json
44601
+ .claude/memory/
44611
44602
  `;
44612
44603
  }
44613
44604
  function docsIndexTemplate(organization) {
44614
44605
  return `---
44615
44606
  title: ${organization}
44616
- description: Documentation for the ${organization} Elevasis project
44607
+ description: Documentation for the ${organization} Elevasis workspace
44617
44608
  order: 1
44618
44609
  ---
44619
44610
 
44620
44611
  # ${organization}
44621
44612
 
44622
- An [Elevasis](https://elevasis.io) project built with the \`@elevasis/sdk\`.
44613
+ An [Elevasis](https://elevasis.io) workspace built with the \`@elevasis/sdk\`.
44623
44614
 
44624
44615
  ## Setup
44625
44616
 
@@ -44642,16 +44633,15 @@ elevasis exec <resourceId> --input '...' # Execute a resource
44642
44633
  elevasis resources # List deployed resources
44643
44634
  elevasis describe <resourceId> # Show resource definition + schemas
44644
44635
  elevasis executions <resourceId> # View execution history
44645
- elevasis env list # List platform env var names
44646
- elevasis env set NAME VALUE # Set env var (requires redeploy)
44647
44636
  \`\`\`
44648
44637
 
44649
44638
  ## Project Structure
44650
44639
 
44651
- - \`elevasis.config.ts\` -- Project config (optional settings)
44652
- - \`src/index.ts\` -- Resource definitions (workflows, agents)
44640
+ - \`elevasis.config.ts\` -- Workspace config (optional settings)
44641
+ - \`src/index.ts\` -- Resource registry (imports and exports all workflows)
44642
+ - \`src/workflows/\` -- Workflow definitions (one per file)
44653
44643
  - \`docs/\` -- Documentation (.mdx files, deployed alongside code)
44654
- - \`.env\` -- API key and environment variables
44644
+ - \`.env\` -- API key for CLI authentication
44655
44645
 
44656
44646
  ## Resources
44657
44647
 
@@ -44672,202 +44662,60 @@ function claudeSettingsTemplate() {
44672
44662
  return JSON.stringify({ autoCompact: false }, null, 2) + "\n";
44673
44663
  }
44674
44664
  function claudeMdTemplate() {
44675
- return `# CLAUDE.md
44676
-
44677
- Project instructions for Claude Code when working with this Elevasis SDK project.
44678
-
44679
- ## Welcome & Profiling
44680
-
44681
- On first interaction, check if \`.claude/profile.json\` exists.
44682
-
44683
- **If it does NOT exist**, run a one-time welcome:
44684
-
44685
- 1. Greet the developer and explain this is a quick one-time setup to personalize help
44686
- 2. Ask these questions:
44687
- - What kind of business or team is this for? (e.g., marketing agency, SaaS, e-commerce)
44688
- - What are the main goals for this project? (e.g., email automation, CRM sync, lead scoring)
44689
- - Which external tools or services will your workflows integrate with? (e.g., Gmail, Attio, Slack)
44690
- - How would you describe your experience with TypeScript and AI automation? (beginner/intermediate/advanced)
44691
- 3. Write answers to \`.claude/profile.json\`:
44692
- \`\`\`json
44693
- {
44694
- "organization": { "name": "", "industry": "", "size": "" },
44695
- "developer": { "experience": "", "aiExperience": "" },
44696
- "project": { "description": "", "existingTools": [], "primaryGoals": [] },
44697
- "preferences": { "verbosity": "concise" }
44698
- }
44699
- \`\`\`
44700
- 4. Summarize what you will help them build and suggest a first resource to create
44701
-
44702
- **If it exists**, read it at session start to personalize your responses (suggest
44703
- relevant tools, calibrate explanation depth, reference their goals).
44704
-
44705
- ## What This Is
44706
-
44707
- An Elevasis SDK project -- external resources (workflows, agents) that deploy to
44708
- the Elevasis platform via \`elevasis deploy\`. The platform handles execution,
44709
- scheduling, and integration tools.
44710
-
44711
- ## Project Structure
44712
-
44713
- - \`src/index.ts\` -- Resource definitions (workflows, agents). Exports
44714
- \`OrganizationResources\` as default export.
44715
- - \`docs/\` -- Documentation files (.mdx). Deployed alongside code, rendered in
44716
- platform UI. Max 100KB per file, 1MB total per deployment.
44717
- - \`elevasis.config.ts\` -- Project configuration (optional).
44718
- - \`.env\` -- API key (\`ELEVASIS_API_KEY\`) and environment variables.
44719
- - \`dist/\` -- Generated by \`elevasis deploy\` (gitignored, never commit).
44720
- - \`.claude/profile.json\` -- Your profile (created on first session, gitignored).
44721
-
44722
- ## CLI Reference
44723
-
44724
- \`\`\`bash
44725
- elevasis check # Validate resource definitions (--entry to override)
44726
- elevasis deploy # Bundle + deploy to platform (--entry, --api-url)
44727
- elevasis exec <id> -i '{"key":"val"}' # Execute a resource (--async for background)
44728
- elevasis resources # List deployed resources (--json)
44729
- elevasis describe <id> # Show resource definition + schemas (--json)
44730
- elevasis executions <id> # Execution history (--limit, --status, --json)
44731
- elevasis execution <id> <execId> # Execution detail (--logs-only, --input, --result)
44732
- elevasis deployments # Deployment history (--json)
44733
- elevasis env list # List platform env var names (--json)
44734
- elevasis env set <NAME> <VALUE> # Set env var (requires redeploy to take effect)
44735
- elevasis env remove <NAME> # Remove env var (requires redeploy to take effect)
44736
- \`\`\`
44737
-
44738
- ## SDK Patterns
44739
-
44740
- ### Single-Step Workflow
44741
-
44742
- \`\`\`typescript
44743
- import type { WorkflowDefinition, OrganizationResources } from '@elevasis/sdk'
44744
- import { z } from 'zod'
44745
-
44746
- const myInput = z.object({ message: z.string() })
44747
- const myOutput = z.object({ result: z.string() })
44748
- type MyInput = z.infer<typeof myInput>
44749
-
44750
- const myWorkflow: WorkflowDefinition = {
44751
- config: {
44752
- resourceId: 'my-workflow',
44753
- name: 'My Workflow',
44754
- type: 'workflow',
44755
- description: 'What it does',
44756
- version: '1.0.0',
44757
- status: 'dev', // 'dev' | 'production'
44758
- },
44759
- contract: {
44760
- inputSchema: myInput,
44761
- outputSchema: myOutput,
44762
- },
44763
- steps: {
44764
- 'process': {
44765
- id: 'process',
44766
- name: 'Process',
44767
- description: 'Process the input',
44768
- handler: async (input) => {
44769
- const { message } = input as MyInput
44770
- return { result: message.toUpperCase() }
44771
- },
44772
- inputSchema: myInput,
44773
- outputSchema: myOutput,
44774
- next: null, // terminal step
44775
- },
44776
- },
44777
- entryPoint: 'process',
44778
- }
44779
-
44780
- const org: OrganizationResources = { workflows: [myWorkflow] }
44781
- export default org
44782
- \`\`\`
44783
-
44784
- ### Multi-Step Workflow
44785
-
44786
- Use \`StepType\` (runtime value) from \`'@elevasis/sdk'\` to chain steps:
44787
-
44788
- \`\`\`typescript
44789
- import { StepType } from '@elevasis/sdk'
44790
-
44791
- steps: {
44792
- 'step-one': {
44793
- id: 'step-one',
44794
- name: 'Step One',
44795
- handler: async (input) => { /* ... */ },
44796
- inputSchema: stepOneInput,
44797
- outputSchema: stepOneOutput,
44798
- next: { type: StepType.LINEAR, target: 'step-two' }, // linear chain
44799
- },
44800
- 'step-two': {
44801
- id: 'step-two',
44802
- name: 'Step Two',
44803
- handler: async (input) => { /* ... */ },
44804
- inputSchema: stepTwoInput,
44805
- outputSchema: stepTwoOutput,
44806
- next: null, // terminal
44807
- },
44808
- },
44809
- entryPoint: 'step-one',
44810
- \`\`\`
44811
-
44812
- ### Conditional Routing
44813
-
44814
- Route to different steps based on output data:
44815
-
44816
- \`\`\`typescript
44817
- import { StepType } from '@elevasis/sdk'
44818
-
44819
- next: {
44820
- type: StepType.CONDITIONAL,
44821
- routes: [
44822
- { target: 'approved', condition: (data: any) => data.score >= 80 },
44823
- { target: 'review', condition: (data: any) => data.score >= 50 },
44824
- ],
44825
- default: 'rejected', // fallback if no condition matches
44826
- },
44827
- \`\`\`
44828
-
44829
- ### Platform Tools
44830
-
44831
- Call 70+ platform tools from step handlers via \`platform.call()\`:
44832
-
44833
- \`\`\`typescript
44834
- import { platform, PlatformToolError } from '@elevasis/sdk/worker'
44835
-
44836
- handler: async (input) => {
44837
- try {
44838
- const result = await platform.call({
44839
- tool: 'gmail', // tool name
44840
- method: 'sendEmail', // method
44841
- params: { to: '...', subject: '...', body: '...' },
44842
- credential: 'my-gmail', // credential name (required for integrations)
44843
- })
44844
- return { sent: true, result }
44845
- } catch (err) {
44846
- if (err instanceof PlatformToolError) {
44847
- console.error(err.code, err.retryable)
44848
- }
44849
- throw err
44850
- }
44851
- }
44852
- \`\`\`
44853
-
44854
- Each \`platform.call()\` has a 60-second timeout. The \`credential\` field names a
44855
- credential configured in the Elevasis platform for your organization.
44856
-
44857
- ### ExecutionContext
44858
-
44859
- Step handlers receive \`(input, context)\`. The context includes:
44860
-
44861
- - \`context.executionId\` -- Unique ID for this execution
44862
- - \`context.organizationId\` -- Your organization ID
44863
- - \`context.resourceId\` -- The resource being executed
44864
- - \`context.logger\` -- \`{ debug, info, warn, error }\` for structured logging
44865
- - \`context.store\` -- \`Map<string, unknown>\` for passing data between steps
44866
-
44867
- ### Zod Schemas
44868
-
44869
- All schemas use Zod 4.1+. Input and output schemas are converted to JSON Schema
44870
- at deploy time via \`z.toJSONSchema()\`.
44665
+ return `<!-- initialized: false -->
44666
+
44667
+ # CLAUDE.md
44668
+
44669
+ ## Session Initialization
44670
+
44671
+ At the start of every session:
44672
+
44673
+ 0. Check the \`<!-- initialized: ... -->\` flag at the top of this file.
44674
+ If \`false\`, read \`.claude/commands/meta.md\` and run the \`/meta init\` flow.
44675
+ After initialization completes, change the flag to \`<!-- initialized: true -->\`.
44676
+ If \`true\`, proceed with steps below.
44677
+ 1. Read \`.claude/memory/profile/skills.md\` -- adapt all responses to the user's
44678
+ assessed skill levels (see Interaction Guidance below).
44679
+ 2. Read \`.claude/memory/index.md\` -- drill into relevant topic files as needed.
44680
+ Balance context relevance against token usage.
44681
+ 3. Check installed \`@elevasis/sdk\` template version against \`templateVersion\`
44682
+ in \`elevasis.config.ts\`. If newer, notify and suggest \`/meta update\`.
44683
+ 4. If \`.claude/memory/\` does not exist, suggest \`/meta init\`.
44684
+ 5. If user TypeScript level is beginner (from skills.md) and
44685
+ \`.claude/memory/tutorial-progress.md\` does not exist, suggest \`/tutorial\`.
44686
+
44687
+ Do this silently. Do not narrate the steps to the user.
44688
+
44689
+ ## Identity
44690
+
44691
+ You are the development agent for an Elevasis workspace. You help the user
44692
+ design, build, and deploy business automation workflows on the Elevasis
44693
+ platform. You are not just a code assistant -- you are a guide who translates
44694
+ business intent into working automation.
44695
+
44696
+ Your users range from experienced developers to business operators who have
44697
+ never written code. Read the user's skill profile at session start and adapt
44698
+ every interaction -- vocabulary, code completeness, explanation depth, and
44699
+ proactivity -- to their assessed levels.
44700
+
44701
+ ## Navigation
44702
+
44703
+ | Resource | Location | When to Load |
44704
+ | --- | --- | --- |
44705
+ | Workspace concepts | \`reference/concepts/index.mdx\` | User asks "what is...?" or needs conceptual grounding |
44706
+ | SDK patterns and examples | \`reference/resources/patterns.mdx\` | Building or modifying a workflow |
44707
+ | Platform tool catalog | \`reference/platform-tools/index.mdx\` | Connecting to external services |
44708
+ | CLI reference | \`reference/cli/index.mdx\` | Running CLI operations |
44709
+ | Credential model | \`reference/security/credentials.mdx\` | Setting up integrations or tool access |
44710
+ | Interaction guidance | \`reference/developer/interaction-guidance.mdx\` | Unsure how to adapt for a skill combination |
44711
+ | Error history | \`.claude/memory/errors/index.md\` | Debugging errors, checking past fixes |
44712
+ | SDK error reference | \`reference/troubleshooting/common-errors.mdx\` | Unknown error not in workspace memory |
44713
+ | Project resource map | \`docs/navigation.mdx\` | Understanding what's deployed |
44714
+ | Project priorities | \`docs/priorities.mdx\` | Deciding what to work on next |
44715
+ | User profile and skills | \`.claude/memory/profile/skills.md\` | Session start (mandatory) |
44716
+ | Cross-session memory | \`.claude/memory/index.md\` | Session start, recalling past context |
44717
+
44718
+ All \`reference/\` paths resolve to \`node_modules/@elevasis/sdk/reference/\`.
44871
44719
 
44872
44720
  ## Rules
44873
44721
 
@@ -44876,22 +44724,95 @@ at deploy time via \`z.toJSONSchema()\`.
44876
44724
  - Do not import from \`@repo/core\` -- use \`@elevasis/sdk\` types only
44877
44725
  - \`StepType\`, \`ExecutionError\`, \`ToolingError\` are runtime imports from \`'@elevasis/sdk'\`
44878
44726
  - \`platform\`, \`PlatformToolError\` are runtime imports from \`'@elevasis/sdk/worker'\`
44879
- - Environment variables go in \`.env\` (never commit API keys)
44880
- - Env vars set via \`elevasis env set\` require \`elevasis deploy\` to take effect
44727
+ - \`.env\` is for CLI authentication only (\`ELEVASIS_API_KEY\`) -- never deployed, never in workers
44728
+ - Integration credentials are managed via the platform credential system (command center UI)
44881
44729
  - Documentation goes in \`docs/\` as \`.mdx\` files
44882
44730
  - \`dist/\` is generated by deploy -- never commit it
44883
44731
  - \`resourceId\` must be lowercase with hyphens, unique per organization
44732
+ - When an error occurs, check \`.claude/memory/errors/\` first for past fixes.
44733
+ If the error is new, check \`reference/troubleshooting/common-errors.mdx\`.
44734
+ After resolving, record the error in \`memory/errors/\` with context and fix.
44735
+ If an error recurs 3+ times, promote it to a rule in this section.
44736
+
44737
+ ## Interaction Guidance
44738
+
44739
+ Adapt your communication based on \`.claude/memory/profile/skills.md\`.
44740
+ Read the profile at session start (Step 1). Adjust every response --
44741
+ vocabulary, code completeness, explanation depth, and proactivity --
44742
+ based on what you find.
44743
+
44744
+ - Match vocabulary to the user's level. Avoid jargon for beginners;
44745
+ be precise for experts. Define technical terms in parentheses the first time.
44746
+ - Show complete, working files for users below intermediate programming.
44747
+ Never show code fragments they can't place.
44748
+ - Explain "why" before "how" for users new to automation.
44749
+ - For users comfortable with code, focus on SDK-specific patterns.
44750
+ - Leverage domain expertise -- if the user knows sales but not code,
44751
+ ask for business process descriptions and translate.
44752
+ - When growth is observed, note it in the skills.md Growth Log.
44753
+
44754
+ For detailed per-dimension adaptation rules, read
44755
+ \`reference/developer/interaction-guidance.mdx\`.
44756
+
44757
+ ## Commands
44758
+
44759
+ | Command | Purpose |
44760
+ | --- | --- |
44761
+ | \`/meta\` | Project lifecycle: init, status, update, fix, deploy, health, develop |
44762
+ | \`/docs\` | Documentation lifecycle: create, checkpoint, cleanup, resume, verify |
44763
+ | \`/database\` | Database operations: init, browse, query, schema, import |
44764
+ | \`/resource\` | Scaffold a new workflow or agent |
44765
+ | \`/templates\` | Discover and apply workflow templates |
44766
+ | \`/agent\` | Agent development (placeholder) |
44767
+ | \`/tutorial\` | Progressive learning path |
44768
+ | \`/help\` | Command tree and navigation map |
44769
+ | \`/profile\` | View and update developer profile |
44770
+
44771
+ ## Maintaining Memory
44772
+
44773
+ ### What Memory Is
44774
+
44775
+ Memory stores persistent state and observations that inform future sessions.
44776
+ Every file must contain data the agent writes and later reads to make better
44777
+ decisions. File names must clearly indicate they contain state or data
44778
+ (e.g., \`deployment-state.md\`, \`tutorial-progress.md\`, \`skills.md\`).
44779
+
44780
+ Priorities live in \`docs/priorities.mdx\`, not in memory. Memory is for internal
44781
+ agent state; priorities are project documentation the user may also read.
44782
+
44783
+ ### What Memory Is NOT
44784
+
44785
+ Do not store in \`.claude/memory/\`:
44786
+ - Instructions, commands, or procedures (belong in \`.claude/commands/\`)
44787
+ - Reference documentation or teaching material (belong in \`docs/\` or SDK reference)
44788
+ - Templates or boilerplate code
44789
+ - Conversation transcripts or chat history
44790
+ - Anything the agent reads but never updates
44791
+
44792
+ ### Structure
44793
+
44794
+ - \`memory/index.md\` is the root -- maps to topic files and subdirectories
44795
+ - Every subdirectory has its own \`index.md\` mapping to children
44796
+ - Start at the root index and drill down
44797
+ - When a file outgrows a single document, split into a subdirectory
44798
+
44799
+ ### Pruning
44800
+
44801
+ - Keep ~20 recent entries per table; drop stale patterns (30+ days, no recurrence)
44802
+ - If a file/index references a missing child, remove the row
44803
+ - If a child exists without an index entry, add it
44804
+ - If an error pattern recurs 3+ times, promote to Rules above
44884
44805
  `;
44885
44806
  }
44886
44807
  function claudeDocsCommandTemplate() {
44887
44808
  return `# /docs command
44888
44809
 
44889
- You are a documentation assistant for this Elevasis SDK project.
44810
+ You are a documentation assistant for this Elevasis workspace.
44890
44811
 
44891
44812
  ## Context
44892
44813
 
44893
44814
  Read the project's CLAUDE.md and all files in docs/ to understand the project.
44894
- Read src/index.ts to understand the resource definitions.
44815
+ Read src/index.ts and src/workflows/ to understand the resource definitions.
44895
44816
 
44896
44817
  ## Operations
44897
44818
 
@@ -44904,26 +44825,64 @@ Populate with content based on the resource definitions in src/.
44904
44825
 
44905
44826
  **\`review\`:** Review all docs/ files for accuracy against the actual resource
44906
44827
  definitions. Flag mismatches between documented schemas and code.
44828
+
44829
+ **\`checkpoint\`:** Save current work progress for session resume.
44830
+ Create or update \`docs/in-progress/<topic>.mdx\` with:
44831
+ - Current state and decisions made
44832
+ - Remaining work and blockers
44833
+ - Update \`docs/priorities.mdx\` with task status
44834
+
44835
+ **\`cleanup\`:** Move completed documents from \`docs/in-progress/\` to their
44836
+ final location in \`docs/\`. Review each in-progress doc to determine if it's
44837
+ complete. Incomplete docs remain in \`docs/in-progress/\`.
44838
+ Also rebuild \`docs/navigation.mdx\` from the current project state.
44839
+
44840
+ **\`resume\`:** Start-of-session command. Review in-progress docs, priorities,
44841
+ and recent deployment state. Present a summary: what's in progress, what's
44842
+ blocking, what's next. Offer to continue the highest-priority item.
44843
+
44844
+ **\`verify [path]\`:** Cross-reference documentation with the codebase.
44845
+ Read the specified doc (or all docs if no path), compare claims against actual
44846
+ code (resource IDs, schema fields, platform tools used), and report
44847
+ discrepancies. Useful before \`/meta deploy\` to ensure docs are accurate.
44907
44848
  `;
44908
44849
  }
44909
44850
  function claudeResourceCommandTemplate() {
44910
44851
  return `# /resource command
44911
44852
 
44912
- You are a resource scaffolding assistant for this Elevasis SDK project.
44853
+ You are a resource scaffolding assistant for this Elevasis workspace.
44913
44854
 
44914
44855
  ## Context
44915
44856
 
44916
- Read CLAUDE.md for SDK patterns (single-step, multi-step, conditional, platform tools).
44917
- Read src/index.ts for existing resource definitions and the OrganizationResources export.
44857
+ Read CLAUDE.md for navigation to SDK patterns (reference/resources/patterns.mdx).
44858
+ Read src/index.ts for the registry and src/workflows/ for existing resources.
44859
+
44860
+ Before suggesting tools, read \`.claude/memory/profile/identity.md\` if it exists
44861
+ to check the user's known integrations and suggest relevant platform tools.
44862
+
44863
+ ## Guided Mode
44864
+
44865
+ Before any operation, check \`.claude/memory/profile/skills.md\`. If the user's
44866
+ programming level is \`none\` or \`minimal\`, or automation level is \`none\`,
44867
+ activate Guided Mode:
44868
+
44869
+ 1. Ask: "What does this workflow need to do?" -- let user describe in plain English
44870
+ 2. Based on description, suggest a resourceId, input schema fields, output schema
44871
+ fields, and whether platform tools are needed
44872
+ 3. Show suggestions and ask for confirmation before generating code
44873
+ 4. Generate the complete resource using the confirmed structure
44874
+
44875
+ This wraps existing operations with conversational discovery for users who
44876
+ cannot specify schemas directly.
44918
44877
 
44919
44878
  ## Operations
44920
44879
 
44921
- **\`workflow <name>\`:** Create a new single-step workflow definition with:
44880
+ **\`workflow <name>\`:** Create a new workflow in \`src/workflows/<name>.ts\` with:
44922
44881
  - Zod input/output schemas with \`z.infer\` type aliases
44923
44882
  - Config object (resourceId, name, type, description, version, status)
44924
44883
  - Contract with schemas
44925
44884
  - Step definition with handler
44926
- - Add to the OrganizationResources export
44885
+ - Add the import to \`src/index.ts\` registry
44927
44886
 
44928
44887
  **\`multi-step <name>\`:** Create a multi-step workflow with:
44929
44888
  - Multiple steps connected via StepType.LINEAR or StepType.CONDITIONAL
@@ -44932,6 +44891,7 @@ Read src/index.ts for existing resource definitions and the OrganizationResource
44932
44891
  - Linear: \`next: { type: StepType.LINEAR, target: 'step-two' }\`
44933
44892
  - Conditional: \`next: { type: StepType.CONDITIONAL, routes: [...], default: 'fallback' }\`
44934
44893
  - Last step: \`next: null\`
44894
+ - Add to \`src/index.ts\` registry
44935
44895
 
44936
44896
  **\`tool-step <name>\`:** Create a step that calls a platform tool:
44937
44897
  - Import \`{ platform, PlatformToolError }\` from '@elevasis/sdk/worker'
@@ -44940,106 +44900,479 @@ Read src/index.ts for existing resource definitions and the OrganizationResource
44940
44900
  - Note: 60s timeout per call, credential required for integration tools
44941
44901
  `;
44942
44902
  }
44943
- function claudeDeployCommandTemplate() {
44944
- return `# /deploy command
44903
+ function claudeTutorialCommandTemplate() {
44904
+ return `# /tutorial command
44945
44905
 
44946
- You are a deployment assistant for this Elevasis SDK project.
44906
+ You are a tutorial guide for this Elevasis workspace.
44947
44907
 
44948
- ## Pre-deploy Checklist
44908
+ ## Context
44949
44909
 
44950
- Before deploying, verify:
44951
- 1. Run \`elevasis check\` -- fix any validation errors
44952
- 2. Ensure .env has ELEVASIS_API_KEY set
44953
- 3. Review resource status fields (dev vs production)
44910
+ Read \`.claude/memory/profile/skills.md\` to adapt lesson pacing and vocabulary.
44911
+ Read \`.claude/memory/tutorial-progress.md\` to check current lesson progress.
44912
+ Read \`reference/concepts/index.mdx\` for teaching vocabulary and concept definitions.
44913
+
44914
+ ## Invocation
44915
+
44916
+ - \`/tutorial\` -- Resume from current lesson. If no progress exists, start Lesson 1.
44917
+ - \`/tutorial start\` -- Reset progress and begin from Lesson 1.
44918
+ - \`/tutorial <number>\` -- Jump to a specific lesson (1-7).
44919
+
44920
+ ## Lesson Flow
44921
+
44922
+ Each lesson follows this flow:
44923
+ 1. Announce lesson title and what they'll learn (1-2 sentences)
44924
+ 2. Explain the concept (read concepts page, adapt to skill level)
44925
+ 3. Guide user to build or modify something (show complete code for beginners)
44926
+ 4. Verify it works (run CLI command, check output)
44927
+ 5. Celebrate success, record observations in \`.claude/memory/tutorial-progress.md\`
44928
+ 6. Ask: "Ready for the next lesson, or want to practice more?"
44929
+
44930
+ ## Lessons
44931
+
44932
+ **Lesson 1: Welcome & Orientation**
44933
+ Tour project files: src/index.ts (registry), src/workflows/echo.ts (starter
44934
+ workflow), elevasis.config.ts, .env, docs/. Explain the execution model.
44935
+ Verify: run \`elevasis resources\`. Observation focus: cloud deployment model.
44936
+
44937
+ **Lesson 2: Your First Custom Workflow**
44938
+ Modify the echo workflow. Walk through each part: config, contract, steps,
44939
+ entryPoint. Deploy: \`elevasis check\` then \`elevasis deploy\`. Test with
44940
+ \`elevasis exec echo --input '{"message":"hello"}'\`.
44941
+ Observation focus: TypeScript syntax comfort.
44942
+
44943
+ **Lesson 3: Understanding Data (Schemas)**
44944
+ Explain schemas in plain English (concepts page). Show common Zod types.
44945
+ Explain \`z.infer\`. Build a new workflow with real-world input schema based
44946
+ on the user's goals (read .claude/memory/profile/identity.md).
44947
+ Observation focus: optional fields, types, suggesting own fields.
44948
+
44949
+ **Lesson 4: Using Platform Tools**
44950
+ Explain platform tools (concepts page). Browse available tools via
44951
+ reference/platform-tools/index.mdx. Pick a tool based on user's goals.
44952
+ Build: add a platform.call() step. Explain credential setup.
44953
+ Observation focus: credential model, async/await.
44954
+
44955
+ **Lesson 5: Multi-Step Workflows**
44956
+ Chain steps with StepType.LINEAR. Build a 2-step workflow. Explain data
44957
+ flow between steps. Deploy and test.
44958
+ Observation focus: data flow reasoning.
44959
+
44960
+ **Lesson 6: Decision Points**
44961
+ Conditional routing with StepType.CONDITIONAL. Add a condition to the
44962
+ multi-step workflow from Lesson 5. Test both paths.
44963
+ Observation focus: branching logic reasoning.
44964
+
44965
+ **Lesson 7: Going to Production**
44966
+ Change status from dev to production. Show monitoring: elevasis executions,
44967
+ elevasis execution. Cover error handling: try/catch, ExecutionError,
44968
+ PlatformToolError. Suggest next steps based on goals.
44969
+ Observation focus: readiness for independent development.
44970
+
44971
+ ## Adaptation Rules
44972
+
44973
+ - If user is intermediate/advanced (from skills.md), condense explanations
44974
+ - If user struggles, slow down with more plain-English explanation
44975
+ - If user is fast, acknowledge and offer to skip ahead
44976
+ - After each lesson, update \`.claude/memory/tutorial-progress.md\`
44977
+ - If user demonstrates a level change, promote to skills.md Growth Log
44978
+
44979
+ ## Progress Format
44980
+
44981
+ Store in \`.claude/memory/tutorial-progress.md\`:
44982
+ - Current Lesson number
44983
+ - Started and Last Session dates
44984
+ - Completed Lessons table (lesson, title, completed, duration)
44985
+ - Capability Observations table (lesson, observation)
44986
+ - Assessment Notes (bullet points)
44987
+ `;
44988
+ }
44989
+ function claudeHelpCommandTemplate() {
44990
+ return `# /help command
44991
+
44992
+ You are a navigation assistant for this Elevasis workspace.
44993
+
44994
+ ## Operations
44995
+
44996
+ **\`/help\` (no args):** Display the full command tree:
44997
+
44998
+ \`\`\`
44999
+ Available Commands:
45000
+
45001
+ /meta Project lifecycle
45002
+ /meta init First-run setup and onboarding
45003
+ /meta status Project health and template version
45004
+ /meta update SDK upgrade and template merge
45005
+ /meta fix Drift repair
45006
+ /meta deploy Full deploy pipeline (validate, git, deploy, verify)
45007
+ /meta health Execution debugging and resource status
45008
+ /meta develop Development navigation hub (resources, tools, examples)
45009
+
45010
+ /docs Documentation lifecycle
45011
+ /docs Show documentation status
45012
+ /docs create Create new documentation page
45013
+ /docs checkpoint Save progress for session resume
45014
+ /docs cleanup Move completed docs, rebuild navigation maps
45015
+ /docs resume Review in-progress work and priorities
45016
+ /docs verify Cross-reference docs with codebase for accuracy
45017
+
45018
+ /database Database operations
45019
+ /database init Connect Supabase project
45020
+ /database browse Query and display table contents
45021
+ /database query Run filtered queries
45022
+ /database schema View/compare schema documentation
45023
+ /database import Import CSV/JSON data
45024
+
45025
+ /resource Scaffold a new workflow or agent
45026
+ /templates Discover and apply workflow templates
45027
+ /agent Agent development (placeholder)
45028
+ /tutorial Progressive learning path
45029
+ /profile View and update developer profile
45030
+ /help This help menu
45031
+
45032
+ Navigation:
45033
+ - docs/navigation.mdx Resource and documentation map
45034
+ - docs/priorities.mdx Current goals and priorities
45035
+ - memory/index.md Cross-session knowledge
45036
+ \`\`\`
45037
+
45038
+ **\`/help <command>\`:** Show detailed help for a specific command with its
45039
+ subcommands and usage examples. Read the corresponding command file at
45040
+ \`.claude/commands/<command>.md\` and present a summary.
45041
+ `;
45042
+ }
45043
+ function claudeTemplatesCommandTemplate() {
45044
+ return `# /templates command
45045
+
45046
+ You are a workflow template assistant for this Elevasis workspace.
45047
+
45048
+ ## Context
45049
+
45050
+ Read \`reference/templates/\` in node_modules/@elevasis/sdk/reference/templates/
45051
+ for available template definitions. Read src/index.ts for the current registry.
45052
+ Read \`.claude/memory/profile/skills.md\` to adapt generated code to skill level.
44954
45053
 
44955
45054
  ## Operations
44956
45055
 
44957
- **No arguments (default):**
44958
- 1. Run \`elevasis check\` to validate
44959
- 2. If check passes, run \`elevasis deploy\`
44960
- 3. If deploy fails, analyze the error and suggest fixes
45056
+ **\`/templates\` (no args):** Show available template categories:
45057
+ - Data Collection (web scraper, RSS feed reader, form handler)
45058
+ - Data Processing (CSV import, data enrichment, deduplication)
45059
+ - Communication (email sender, notification dispatcher)
45060
+ - CRM (contact sync, lead scoring, pipeline update)
45061
+ - Documents (PDF generator, report builder, invoice creator)
45062
+ - AI (text classifier, data extractor, summarizer)
45063
+ - Scheduling (recurring job, delayed task, batch processor)
45064
+
45065
+ **\`/templates <category>\`:** Show templates in the category with descriptions.
45066
+
45067
+ **\`/templates apply <name>\`:** Generate a workflow from the template:
45068
+ 1. Read the template definition from reference/templates/<name>.mdx
45069
+ 2. Generate a workflow file in src/workflows/<name>.ts
45070
+ 3. Add the import to src/index.ts registry
45071
+ 4. If the template uses platform tools, prompt for credential setup
45072
+ 5. If the template uses the database, check that /database init has been run
45073
+ 6. Run \`elevasis check\` to validate
45074
+
45075
+ Templates are documentation-based. The agent reads the template definition
45076
+ and generates context-aware code adapted to the user's existing schemas,
45077
+ credentials, skill level, and naming conventions.
45078
+ `;
45079
+ }
45080
+ function claudeDatabaseCommandTemplate() {
45081
+ return `# /database command
45082
+
45083
+ You are a database assistant for this Elevasis workspace.
45084
+
45085
+ ## Context
45086
+
45087
+ Read \`data/schema.ts\` if it exists for the current schema documentation.
45088
+ Read \`.claude/memory/deployment-state.md\` for database connection status.
45089
+ Read \`.claude/memory/profile/skills.md\` to adapt explanations.
45090
+
45091
+ ## Operations
45092
+
45093
+ **\`/database init\`:** Guide user through Supabase project setup:
45094
+ 1. Explain Supabase (free, great dashboard, integrates with workflows)
45095
+ 2. Walk through: create project at supabase.com/dashboard
45096
+ 3. Collect Project URL and service_role key
45097
+ 4. Store as platform credential named 'my-database' via command center
45098
+ 5. Test connection
45099
+ 6. Create data/schema.ts with initial table documentation
45100
+ 7. Record database connection in memory/deployment-state.md
45101
+
45102
+ **\`/database\` (no args):** Show database connection status, tables, row counts.
45103
+
45104
+ **\`/database add <table>\`:** Create a migration script:
45105
+ 1. Generate scripts/migrations/NNN-create-<table>.ts
45106
+ 2. Show the script and explain each statement
45107
+ 3. Confirm before execution
45108
+ 4. Update data/schema.ts and docs/database.mdx
45109
+
45110
+ **\`/database browse <table>\`:** Query and display table contents via CLI.
45111
+
45112
+ **\`/database schema\`:** Show data/schema.ts contents, compare against live DB.
45113
+
45114
+ **\`/database import <table> --file <path>\`:** Import CSV/JSON into a table.
44961
45115
 
44962
- **\`status\`:** Run \`elevasis deployments\` to show current deployment status,
44963
- then \`elevasis resources\` to list deployed resources.
45116
+ ## Database Safety
45117
+
45118
+ ALWAYS confirm with the user before:
45119
+ - DROP TABLE or DROP COLUMN operations
45120
+ - DELETE without a WHERE clause (bulk delete)
45121
+ - TRUNCATE operations
45122
+ - ALTER TABLE that removes columns
45123
+ - Any operation that cannot be undone
45124
+
45125
+ For read operations and targeted writes (INSERT, UPDATE with WHERE),
45126
+ proceed normally.
45127
+
45128
+ ## Supabase Platform Tool
45129
+
45130
+ Workflows access the database via platform.call({ tool: 'supabase', ... }).
45131
+ Methods: insert, select, update, delete, upsert, rpc, count.
45132
+ Filter syntax uses PostgREST format (eq, neq, gt, gte, lt, lte, like, ilike, in, is).
45133
+ `;
45134
+ }
45135
+ function claudeAgentCommandTemplate() {
45136
+ return `# /agent command
45137
+
45138
+ You are an agent development assistant for this Elevasis workspace.
45139
+
45140
+ ## Current State
45141
+
45142
+ Agent definitions are accepted by the SDK and appear in the registry.
45143
+ Autonomous agent execution (multi-turn tool use loops) is deferred.
45144
+ LLM calls are available via \`platform.call({ tool: 'llm' })\` as a workaround.
45145
+
45146
+ ## Operations
45147
+
45148
+ **\`/agent\` (no args):** Explain the current state:
45149
+ - Agent definitions are accepted by the SDK and appear in the registry
45150
+ - Autonomous agent execution (multi-turn tool use loops) is deferred
45151
+ - LLM calls are available via platform.call({ tool: 'llm' }) as a workaround
45152
+ - Show the AgentDefinition pattern for future use
45153
+
45154
+ **\`/agent scaffold <name>\`:** Create an agent definition with:
45155
+ - Config (resourceId, name, type, description, version, status)
45156
+ - System prompt
45157
+ - Available tools list
45158
+ - Note that execution will fail until agent runtime is implemented
45159
+ - Add to src/index.ts registry
44964
45160
  `;
44965
45161
  }
44966
- function claudeInspectCommandTemplate() {
44967
- return `# /inspect command
45162
+ function claudeProfileCommandTemplate() {
45163
+ return `# /profile command
44968
45164
 
44969
- You are a deployment health and execution debugging assistant.
45165
+ You are a profile management assistant for this Elevasis workspace.
44970
45166
 
44971
45167
  ## Context
44972
45168
 
44973
- Read CLAUDE.md for project context and CLI reference.
45169
+ Read \`.claude/memory/profile/index.md\` to discover profile sub-files.
45170
+ Read the sub-files (identity.md, skills.md, preferences.md) to load the current profile.
45171
+
45172
+ If \`.claude/memory/profile/\` does not exist, suggest running \`/meta init\` to create it.
44974
45173
 
44975
45174
  ## Operations
44976
45175
 
44977
- **No arguments (default):** Run a health overview:
44978
- 1. Run \`elevasis deployments\` to show deployment status
44979
- 2. Run \`elevasis resources\` to list deployed resources
44980
- 3. Summarize: deployment age, resource count, any issues
44981
-
44982
- **\`executions <resourceId>\`:** Show execution history:
44983
- 1. Run \`elevasis executions <resourceId>\`
44984
- 2. Summarize: success/failure counts, recent trends
44985
- 3. If failures exist, suggest drilling into specific executions
44986
-
44987
- **\`describe <resourceId>\`:** Show resource schemas:
44988
- 1. Run \`elevasis describe <resourceId>\`
44989
- 2. Display input/output schemas in a readable format
44990
- 3. Generate an example \`elevasis exec\` command from the input schema
44991
-
44992
- **\`execution <resourceId> <executionId>\`:** Drill into a specific execution:
44993
- 1. Run \`elevasis execution <resourceId> <executionId>\`
44994
- 2. Show status, timing, input, output
44995
- 3. If failed, analyze the error and suggest fixes
44996
-
44997
- **\`failed <resourceId>\`:** Find and analyze recent failures:
44998
- 1. Run \`elevasis executions <resourceId> --status failed --limit 5\`
44999
- 2. For each failure, run \`elevasis execution <resourceId> <id> --logs-only\`
45000
- 3. Identify patterns and suggest fixes
45176
+ **No arguments (default):** Display the current profile in a readable format.
45177
+ Show organization, industry, experience level, goals, known integrations, and preferences.
45178
+ Ask if anything needs updating.
45179
+
45180
+ **\`update\`:** Walk through each profile section, showing current values and
45181
+ asking if they should change. Only update fields the user wants to change.
45182
+ Write changes to the appropriate memory/profile/ file.
45183
+
45184
+ **\`level\`:** Assess the user's current skill level based on their project
45185
+ history (resources created, successful deploys, error handling patterns).
45186
+ Suggest updating memory/profile/skills.md if the assessment differs from the stored level.
45187
+
45188
+ **\`assess\`:** Re-run the competency assessment questions from /meta init.
45189
+ Update all skill dimensions in memory/profile/skills.md.
45001
45190
  `;
45002
45191
  }
45003
- function claudeEnvCommandTemplate() {
45004
- return `# /env command
45192
+ function claudeMetaCommandTemplate() {
45193
+ return `# /meta command
45005
45194
 
45006
- You are an environment variable management assistant.
45195
+ You are a project management assistant for this Elevasis workspace.
45007
45196
 
45008
45197
  ## Context
45009
45198
 
45010
- Read CLAUDE.md for project context and CLI reference.
45011
- Read .env for local environment variables.
45199
+ Read \`elevasis.config.ts\` to get the current \`templateVersion\`.
45200
+ Read \`package.json\` to get the installed \`@elevasis/sdk\` version.
45201
+ Read \`.claude/memory/index.md\` if it exists for project state.
45012
45202
 
45013
45203
  ## Operations
45014
45204
 
45015
- **No arguments (default):** Compare local vs platform:
45016
- 1. Read .env file and extract variable names
45017
- 2. Run \`elevasis env list\` to get platform variables
45018
- 3. Show comparison: what is local-only, platform-only, or in both
45019
- 4. Suggest actions for any mismatches
45020
-
45021
- **\`set <NAME> <VALUE>\`:** Set a platform variable:
45022
- 1. Run \`elevasis env set <NAME> <VALUE>\`
45023
- 2. Remind user to redeploy: \`elevasis deploy\`
45024
-
45025
- **\`sync\`:** Walk .env and sync to platform:
45026
- 1. Read .env file
45027
- 2. For each variable (except ELEVASIS_API_KEY), check if it exists on platform
45028
- 3. Show what would be added/updated
45029
- 4. Ask for confirmation before running \`elevasis env set\` for each
45030
- 5. Remind user to redeploy after syncing
45205
+ ### \`/meta init\` -- First-Run Setup
45206
+
45207
+ Guided setup for a freshly scaffolded workspace. Triggered automatically
45208
+ by the \`<!-- initialized: false -->\` flag in CLAUDE.md, or run manually.
45209
+
45210
+ 1. **Install dependencies**
45211
+ Run \`pnpm install\`. Wait for completion. Report any errors.
45212
+
45213
+ 2. **Setup environment**
45214
+ Check if \`.env\` has \`ELEVASIS_API_KEY\` set.
45215
+ If not, ask the user for their API key and write it to \`.env\`.
45216
+ Validate the key works: run \`elevasis resources\` (should return empty list,
45217
+ not an auth error).
45218
+
45219
+ 3. **Competency Assessment**
45220
+ Ask these questions to build the user's profile:
45221
+
45222
+ Identity & Goals (3 questions):
45223
+ - "What does your business or team do?"
45224
+ - "What do you want to automate with Elevasis?"
45225
+ - "Which tools does your team already use?" (email, CRM, spreadsheets, etc.)
45226
+
45227
+ Competency (2-3 questions with conditional skipping):
45228
+ - "Have you written code before? If so, what kind?"
45229
+ No code -> programming: none, skip next question
45230
+ HTML/CSS/Excel -> programming: minimal, skip next question
45231
+ Scripts/websites -> programming: intermediate, ask next question
45232
+ Production apps -> programming: advanced, ask next question
45233
+ - (Only if scripts+) "Have you used TypeScript or a typed language?"
45234
+ No -> typescript: none
45235
+ Read it / used typed language -> typescript: exposure
45236
+ Written TypeScript projects -> typescript: proficient
45237
+ - "Have you used automation tools? (Zapier, Make, cron jobs, scripts)"
45238
+ No -> automation: none
45239
+ Zapier/Make flows -> automation: low-code
45240
+ Custom scripts -> automation: custom
45241
+
45242
+ Communication (1 question):
45243
+ - "Step-by-step explanations or concise answers?"
45244
+
45245
+ Write responses to memory:
45246
+ - Create \`.claude/memory/index.md\` (root index)
45247
+ - Create \`.claude/memory/profile/index.md\` (profile index)
45248
+ - Create \`.claude/memory/profile/identity.md\` (org, goals, tools)
45249
+ - Create \`.claude/memory/profile/skills.md\` (multi-dimensional assessment)
45250
+ - Create \`.claude/memory/profile/preferences.md\` (verbosity, guidance)
45251
+
45252
+ 4. **Git check**
45253
+ - If \`.git/\` exists: note git is configured in memory/profile/preferences.md
45254
+ - If \`.git/\` does not exist: suggest \`git init\` and optionally GitHub
45255
+ - If git remote exists: note remote URL in memory/profile/preferences.md
45256
+
45257
+ 5. **Verify project**
45258
+ Run \`elevasis check\` to confirm the starter resource is valid.
45259
+ Optionally deploy the echo workflow.
45260
+
45261
+ 6. **Report**
45262
+ Summary of what was set up. Suggest next steps based on goals.
45263
+
45264
+ If the user's TypeScript level is beginner or automation level is new,
45265
+ suggest /tutorial start: "I recommend starting with /tutorial -- it walks
45266
+ you through building workflows step by step, at your own pace."
45267
+
45268
+ 7. **Update flag**
45269
+ Change \`<!-- initialized: false -->\` to \`<!-- initialized: true -->\`
45270
+ in CLAUDE.md.
45271
+
45272
+ ### \`/meta\` (no arguments) -- Project Status
45273
+
45274
+ Display a project health summary:
45275
+ 1. Current template version vs latest available
45276
+ 2. SDK package version from package.json
45277
+ 3. Profile summary (from memory/profile/skills.md)
45278
+ 4. Quick drift check: count of missing managed files, missing gitignore entries
45279
+
45280
+ ### \`/meta update\` -- Full Upgrade
45281
+
45282
+ Upgrade the SDK and merge template changes:
45283
+
45284
+ 1. Run \`pnpm update @elevasis/sdk\` to pull the latest SDK
45285
+ 2. Run \`elevasis update\` to add missing files and flag conflicts
45286
+ 3. For each flagged file in the output:
45287
+ - Read the current project file
45288
+ - Read the new template from \`@elevasis/sdk/templates\`
45289
+ - Compare and merge intelligently:
45290
+ - Add new sections that don't exist
45291
+ - Preserve user customizations
45292
+ - If a section differs, show both versions and let user choose
45293
+ 4. Return a report of changes
45294
+
45295
+ ### \`/meta fix\` -- Fix Drift
45296
+
45297
+ Detect and repair drift without a version upgrade:
45298
+
45299
+ 1. **Missing managed files:** Regenerate from templates
45300
+ 2. **Gitignore drift:** Append missing entries
45301
+ 3. **CLAUDE.md sections:** Add missing sections in correct position
45302
+ 4. **Memory structure:** Verify index consistency
45303
+ 5. **Doc cross-references:** Scan for broken links
45304
+ 6. **Settings consistency:** Verify expected fields
45305
+
45306
+ ### \`/meta deploy\` -- Full Deploy Pipeline
45307
+
45308
+ 1. Run \`elevasis check\` (validation)
45309
+ 2. Type check if \`tsconfig.json\` exists
45310
+ 3. Verify docs reflect current resources
45311
+ 4. If git configured: stage changes, commit with deploy message
45312
+ 5. Run \`elevasis deploy\`
45313
+ 6. Bump deployment version in \`docs/navigation.mdx\` metadata
45314
+ 7. Verify deployment via platform
45315
+ 8. Update \`memory/deployment-state.md\` with count, timestamp, inventory
45316
+ 9. If git configured and remote exists: optionally push
45317
+
45318
+ Each step reports its result. Pipeline stops on failure with suggested fix.
45319
+
45320
+ ### \`/meta health\` -- Execution Debugging
45321
+
45322
+ Renamed from /inspect. Checks:
45323
+ - Show recent executions with status (completed/failed)
45324
+ - For failed executions: analyze logs, cross-reference with memory/errors/
45325
+ - Check resource deployment status (deployed, outdated, never deployed)
45326
+ - Verify environment: API key valid, credentials accessible, DB connected
45327
+
45328
+ ### \`/meta develop\` -- Development Navigation Hub
45329
+
45330
+ Primary development entry point. Loads a navigation map and offers actions.
45331
+
45332
+ 1. **Project Resource Map** -- from docs/navigation.mdx. Shows deployed
45333
+ resources: resourceId, name, status, tools used, last deployment.
45334
+ 2. **Development Actions** -- contextual based on resource map:
45335
+ - Edit/extend a workflow
45336
+ - Test a workflow
45337
+ - Debug a failed execution
45338
+ - Browse platform tools (read reference/platform-tools/index.mdx)
45339
+ - Set up credentials
45340
+ - View examples (read reference/resources/patterns.mdx)
45341
+ 3. **SDK Reference Navigation** -- pointers to reference files
45342
+ 4. **Upkeep Detection** -- check navigation freshness, in-progress items,
45343
+ pending priorities. Suggest /docs cleanup or /docs resume if needed.
45344
+
45345
+ ## Merge Strategy
45346
+
45347
+ - **CLAUDE.md:** Add new sections in correct position. Preserve customizations.
45348
+ - **Commands:** Usually additive. Show diff for changes.
45349
+ - **.gitignore:** Append-only -- never remove existing entries.
45350
+
45351
+ ## Template Access
45352
+
45353
+ The agent reads current templates from the installed SDK:
45354
+ \`@elevasis/sdk/templates\` subpath exports all template functions.
45031
45355
  `;
45032
45356
  }
45033
45357
  function starterTemplate() {
45034
- return `import type { WorkflowDefinition, OrganizationResources } from '@elevasis/sdk'
45358
+ return `import type { OrganizationResources } from '@elevasis/sdk'
45359
+ import { echo } from './workflows/echo.js'
45360
+
45361
+ const org: OrganizationResources = {
45362
+ workflows: [echo],
45363
+ }
45364
+ export default org
45365
+ `;
45366
+ }
45367
+ function starterWorkflowTemplate() {
45368
+ return `import type { WorkflowDefinition } from '@elevasis/sdk'
45035
45369
  import { z } from 'zod'
45036
45370
 
45037
45371
  const echoInput = z.object({ message: z.string() })
45038
45372
  const echoOutput = z.object({ echo: z.string() })
45039
-
45040
45373
  type EchoInput = z.infer<typeof echoInput>
45041
45374
 
45042
- const echo: WorkflowDefinition = {
45375
+ export const echo: WorkflowDefinition = {
45043
45376
  config: {
45044
45377
  resourceId: 'echo',
45045
45378
  name: 'Echo',
@@ -45053,7 +45386,7 @@ const echo: WorkflowDefinition = {
45053
45386
  outputSchema: echoOutput,
45054
45387
  },
45055
45388
  steps: {
45056
- 'echo': {
45389
+ echo: {
45057
45390
  id: 'echo',
45058
45391
  name: 'Echo Message',
45059
45392
  description: 'Returns the input message',
@@ -45063,73 +45396,158 @@ const echo: WorkflowDefinition = {
45063
45396
  },
45064
45397
  inputSchema: echoInput,
45065
45398
  outputSchema: echoOutput,
45066
- next: null, // terminal step -- single-step workflow
45399
+ next: null,
45067
45400
  },
45068
45401
  },
45069
45402
  entryPoint: 'echo',
45070
45403
  }
45071
-
45072
- const org: OrganizationResources = {
45073
- workflows: [echo],
45074
- }
45075
- export default org
45076
45404
  `;
45077
45405
  }
45078
45406
 
45079
- // src/cli/commands/env.ts
45080
- function registerEnvCommand(program3) {
45081
- const env2 = program3.command("env").description("Manage environment variables for your deployment");
45082
- env2.command("list").description("List environment variable names").option("--api-url <url>", "API URL").option("--json", "Output as JSON").action(wrapAction("env list", async (options2) => {
45083
- const apiUrl = resolveApiUrl(options2.apiUrl);
45084
- const spinner = ora("Fetching environment variables...").start();
45085
- const data = await apiGet(
45086
- "/api/external/env",
45087
- apiUrl
45088
- );
45089
- spinner.stop();
45090
- if (options2.json) {
45091
- console.log(JSON.stringify(data.envVars, null, 2));
45092
- return;
45407
+ // src/cli/commands/update.ts
45408
+ var import_path4 = require("path");
45409
+ var import_promises3 = require("fs/promises");
45410
+ function registerUpdateCommand(program3) {
45411
+ program3.command("update").description("Update project scaffold to latest template version").action(wrapAction("update", async () => {
45412
+ const cwd = process.cwd();
45413
+ const configPath = (0, import_path4.resolve)(cwd, "elevasis.config.ts");
45414
+ let currentVersion = 0;
45415
+ let configContents = "";
45416
+ try {
45417
+ configContents = await (0, import_promises3.readFile)(configPath, "utf-8");
45418
+ const match = configContents.match(/templateVersion:\s*(\d+)/);
45419
+ if (match) {
45420
+ currentVersion = parseInt(match[1], 10);
45421
+ }
45422
+ } catch {
45093
45423
  }
45094
- if (data.envVars.length === 0) {
45095
- console.log(source_default.yellow("No environment variables set."));
45096
- console.log(source_default.gray("Set one with: elevasis env set NAME VALUE"));
45424
+ if (currentVersion >= TEMPLATE_VERSION) {
45425
+ console.log(source_default.green(` Project is up to date (template version ${TEMPLATE_VERSION})`));
45097
45426
  return;
45098
45427
  }
45099
- console.log(source_default.cyan("Environment Variables:"));
45100
- for (const v of data.envVars) {
45101
- console.log(source_default.white(` ${source_default.bold(v.name)} ${source_default.gray(`(updated ${v.updatedAt})`)} ${source_default.gray("********")}`));
45428
+ const templateMap = {
45429
+ "elevasis.config.ts": configTemplate,
45430
+ ".gitignore": gitignoreTemplate,
45431
+ "CLAUDE.md": claudeMdTemplate,
45432
+ ".claude/settings.json": claudeSettingsTemplate,
45433
+ ".claude/commands/docs.md": claudeDocsCommandTemplate,
45434
+ ".claude/commands/resource.md": claudeResourceCommandTemplate,
45435
+ ".claude/commands/tutorial.md": claudeTutorialCommandTemplate,
45436
+ ".claude/commands/help.md": claudeHelpCommandTemplate,
45437
+ ".claude/commands/templates.md": claudeTemplatesCommandTemplate,
45438
+ ".claude/commands/database.md": claudeDatabaseCommandTemplate,
45439
+ ".claude/commands/agent.md": claudeAgentCommandTemplate,
45440
+ ".claude/commands/profile.md": claudeProfileCommandTemplate,
45441
+ ".claude/commands/meta.md": claudeMetaCommandTemplate
45442
+ };
45443
+ const added = [];
45444
+ const flagged = [];
45445
+ const appendedGitignore = [];
45446
+ for (const file2 of MANAGED_FILES) {
45447
+ const filePath = (0, import_path4.resolve)(cwd, file2);
45448
+ const templateFn = templateMap[file2];
45449
+ if (!templateFn) continue;
45450
+ const templateContent = templateFn();
45451
+ if (file2 === ".gitignore") {
45452
+ try {
45453
+ await (0, import_promises3.access)(filePath);
45454
+ const existingContent = await (0, import_promises3.readFile)(filePath, "utf-8");
45455
+ const existingLines = existingContent.split("\n");
45456
+ const templateLines = templateContent.split("\n");
45457
+ const linesToAppend = [];
45458
+ for (const line of templateLines) {
45459
+ if (line.trim() === "") continue;
45460
+ if (!existingLines.includes(line)) {
45461
+ linesToAppend.push(line);
45462
+ }
45463
+ }
45464
+ if (linesToAppend.length > 0) {
45465
+ const appendContent = (existingContent.endsWith("\n") ? "" : "\n") + linesToAppend.join("\n") + "\n";
45466
+ await (0, import_promises3.writeFile)(filePath, existingContent + appendContent, "utf-8");
45467
+ appendedGitignore.push(...linesToAppend);
45468
+ }
45469
+ } catch {
45470
+ await (0, import_promises3.mkdir)((0, import_path4.dirname)(filePath), { recursive: true });
45471
+ await (0, import_promises3.writeFile)(filePath, templateContent, "utf-8");
45472
+ added.push(file2);
45473
+ }
45474
+ continue;
45475
+ }
45476
+ if (file2 === "elevasis.config.ts") {
45477
+ if (configContents) {
45478
+ if (/templateVersion:\s*\d+/.test(configContents)) {
45479
+ const updated = configContents.replace(
45480
+ /templateVersion:\s*\d+/,
45481
+ `templateVersion: ${TEMPLATE_VERSION}`
45482
+ );
45483
+ await (0, import_promises3.writeFile)(filePath, updated, "utf-8");
45484
+ } else {
45485
+ const updated = configContents.replace(
45486
+ /\bexport default\s*\{/,
45487
+ `export default {
45488
+ templateVersion: ${TEMPLATE_VERSION},`
45489
+ );
45490
+ await (0, import_promises3.writeFile)(filePath, updated, "utf-8");
45491
+ }
45492
+ } else {
45493
+ await (0, import_promises3.mkdir)((0, import_path4.dirname)(filePath), { recursive: true });
45494
+ await (0, import_promises3.writeFile)(filePath, templateContent, "utf-8");
45495
+ added.push(file2);
45496
+ }
45497
+ continue;
45498
+ }
45499
+ let exists = false;
45500
+ try {
45501
+ await (0, import_promises3.access)(filePath);
45502
+ exists = true;
45503
+ } catch {
45504
+ }
45505
+ if (!exists) {
45506
+ await (0, import_promises3.mkdir)((0, import_path4.dirname)(filePath), { recursive: true });
45507
+ await (0, import_promises3.writeFile)(filePath, templateContent, "utf-8");
45508
+ added.push(file2);
45509
+ } else {
45510
+ const existingContent = await (0, import_promises3.readFile)(filePath, "utf-8");
45511
+ if (existingContent === templateContent) {
45512
+ } else {
45513
+ flagged.push(file2);
45514
+ }
45515
+ }
45516
+ }
45517
+ console.log("");
45518
+ console.log(source_default.green.bold(` Updated @elevasis/sdk template v${currentVersion} -> v${TEMPLATE_VERSION}`));
45519
+ if (added.length > 0) {
45520
+ console.log("");
45521
+ console.log(" Added:");
45522
+ for (const file2 of added) {
45523
+ console.log(source_default.green(` ${file2}`));
45524
+ }
45102
45525
  }
45103
- console.log(source_default.gray(`
45104
- ${data.envVars.length} variable(s)`));
45105
- }));
45106
- env2.command("set <name> <value>").description("Set an environment variable (creates or updates)").option("--api-url <url>", "API URL").action(wrapAction("env set", async (name, value, options2) => {
45107
- const apiUrl = resolveApiUrl(options2.apiUrl);
45108
- const spinner = ora(`Setting ${name}...`).start();
45109
- await apiPut(
45110
- `/api/external/env/${encodeURIComponent(name)}`,
45111
- { value },
45112
- apiUrl
45113
- );
45114
- spinner.stop();
45115
- console.log(source_default.green(`Set ${source_default.bold(name)}`));
45116
- console.log(source_default.yellow("Redeploy to apply changes: elevasis deploy"));
45117
- }));
45118
- env2.command("remove <name>").description("Remove an environment variable").option("--api-url <url>", "API URL").action(wrapAction("env remove", async (name, options2) => {
45119
- const apiUrl = resolveApiUrl(options2.apiUrl);
45120
- const spinner = ora(`Removing ${name}...`).start();
45121
- await apiDelete(
45122
- `/api/external/env/${encodeURIComponent(name)}`,
45123
- apiUrl
45124
- );
45125
- spinner.stop();
45126
- console.log(source_default.green(`Removed ${source_default.bold(name)}`));
45127
- console.log(source_default.yellow("Redeploy to apply changes: elevasis deploy"));
45526
+ if (appendedGitignore.length > 0) {
45527
+ console.log("");
45528
+ console.log(" Appended to .gitignore:");
45529
+ for (const entry of appendedGitignore) {
45530
+ console.log(source_default.yellow(` ${entry}`));
45531
+ }
45532
+ }
45533
+ if (flagged.length > 0) {
45534
+ console.log("");
45535
+ console.log(" Needs agent review:");
45536
+ for (const file2 of flagged) {
45537
+ console.log(source_default.cyan(` ${file2} (differs from template)`));
45538
+ }
45539
+ }
45540
+ if (flagged.length > 0) {
45541
+ console.log("");
45542
+ console.log(source_default.gray(" Run /meta update in Claude Code to merge flagged files."));
45543
+ console.log(source_default.gray(" Or run /meta fix to verify and repair the full framework."));
45544
+ }
45545
+ console.log("");
45128
45546
  }));
45129
45547
  }
45130
45548
 
45131
45549
  // src/cli/index.ts
45132
- (0, import_dotenv.config)({ path: (0, import_path4.resolve)(process.cwd(), ".env"), override: false });
45550
+ (0, import_dotenv.config)({ path: (0, import_path5.resolve)(process.cwd(), ".env"), override: false });
45133
45551
  var program2 = new Command();
45134
45552
  program2.name("elevasis").description(
45135
45553
  source_default.cyan("Elevasis SDK CLI") + `
@@ -45143,10 +45561,8 @@ Commands:
45143
45561
  elevasis executions <resourceId> List execution history
45144
45562
  elevasis execution <resourceId> <id> Get execution details
45145
45563
  elevasis deployments List deployments
45146
- elevasis env list List environment variables
45147
- elevasis env set NAME VALUE Set an environment variable
45148
- elevasis env remove NAME Remove an environment variable
45149
- elevasis init [directory] Scaffold a new project
45564
+ elevasis update Update workspace scaffold to latest template
45565
+ elevasis init [directory] Scaffold a new workspace
45150
45566
 
45151
45567
  Use "elevasis <command> --help" for more information about a command.`
45152
45568
  ).version(SDK_VERSION);
@@ -45159,7 +45575,7 @@ registerExecutionCommand(program2);
45159
45575
  registerDescribeCommand(program2);
45160
45576
  registerDeploymentsCommand(program2);
45161
45577
  registerInitCommand(program2);
45162
- registerEnvCommand(program2);
45578
+ registerUpdateCommand(program2);
45163
45579
  program2.parse();
45164
45580
  /*! Bundled license information:
45165
45581