@elevasis/sdk 0.5.1 → 0.5.3

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.
package/dist/templates.js CHANGED
@@ -1,6 +1,17 @@
1
1
  // package.json
2
2
 
3
3
  // src/cli/commands/templates/core/workspace.ts
4
+ var TEMPLATE_VERSION = 21;
5
+ function configTemplate() {
6
+ return `import type { ElevasConfig } from '@elevasis/sdk'
7
+
8
+ export default {
9
+ templateVersion: ${TEMPLATE_VERSION},
10
+ // defaultStatus: 'dev', // Default status for new resources ('dev' | 'production')
11
+ // dev: { port: 5170 }, // Local API port (internal development only)
12
+ } satisfies ElevasConfig
13
+ `;
14
+ }
4
15
  function gitignoreTemplate(ctx = {}) {
5
16
  let content = `node_modules/
6
17
  .env
@@ -19,7 +30,157 @@ ui/dist/
19
30
 
20
31
  // src/cli/commands/templates/core/claude.ts
21
32
  function claudeSettingsTemplate() {
22
- return JSON.stringify({ autoCompact: false }, null, 2) + "\n";
33
+ return JSON.stringify({
34
+ autoCompact: false,
35
+ hooks: {
36
+ PreToolUse: [
37
+ {
38
+ matcher: "Write|Edit|MultiEdit|Bash",
39
+ hooks: [
40
+ {
41
+ type: "command",
42
+ command: "node .claude/hooks/enforce-sdk-boundary.mjs"
43
+ }
44
+ ]
45
+ }
46
+ ]
47
+ }
48
+ }, null, 2) + "\n";
49
+ }
50
+ function claudeSdkBoundaryHookTemplate() {
51
+ return String.raw`#!/usr/bin/env node
52
+ // enforce-sdk-boundary.mjs
53
+ // Blocks gh CLI, destructive git operations, and file writes outside the project root.
54
+ // Allows git add, commit, push, pull, fetch -- used by /meta deploy.
55
+
56
+ import { resolve, normalize } from "node:path";
57
+ import { appendFileSync, mkdirSync } from "node:fs";
58
+
59
+ const LOG_DIR = (process.env.CLAUDE_PROJECT_DIR ?? process.cwd()) + "/.claude/logs";
60
+ const LOG_FILE = LOG_DIR + "/boundary-hook.log";
61
+
62
+ function log(msg) {
63
+ try {
64
+ mkdirSync(LOG_DIR, { recursive: true });
65
+ appendFileSync(LOG_FILE, "[" + new Date().toISOString() + "] " + msg + "\n");
66
+ } catch {}
67
+ }
68
+
69
+ function deny(reason) {
70
+ log("DENY -- " + reason);
71
+ process.stdout.write(
72
+ JSON.stringify({
73
+ hookSpecificOutput: {
74
+ hookEventName: "PreToolUse",
75
+ permissionDecision: "deny",
76
+ permissionDecisionReason: reason,
77
+ },
78
+ })
79
+ );
80
+ }
81
+
82
+ try {
83
+ const chunks = [];
84
+ for await (const chunk of process.stdin) chunks.push(chunk);
85
+ const input = JSON.parse(Buffer.concat(chunks).toString());
86
+
87
+ const projectDir = normalize(process.env.CLAUDE_PROJECT_DIR ?? process.cwd());
88
+ const sep = process.platform === "win32" ? "\\" : "/";
89
+ const prefix = projectDir.endsWith("\\") || projectDir.endsWith("/") ? projectDir : projectDir + sep;
90
+
91
+ function isOutside(filePath) {
92
+ const target = normalize(resolve(filePath));
93
+ return !target.startsWith(prefix) && target !== projectDir;
94
+ }
95
+
96
+ if (input.tool_name === "Bash") {
97
+ const cmd = input.tool_input?.command ?? "";
98
+
99
+ // GitHub CLI -- blocked (affects shared remote state, user-initiated only)
100
+ if (/\bgh\b/.test(cmd)) {
101
+ deny(
102
+ "BLOCKED: GitHub CLI (gh) command detected.\n" +
103
+ "WHY: GitHub CLI operations affect shared remote state (PRs, issues, releases). These must be user-initiated.\n" +
104
+ "INSTEAD: Ask the user to run this gh command manually."
105
+ );
106
+ process.exit(0);
107
+ }
108
+
109
+ // Destructive git -- blocked
110
+ if (/(?<!-)\bgit\s+reset\b/.test(cmd) && /--hard/.test(cmd)) {
111
+ deny(
112
+ "BLOCKED: git reset --hard detected.\n" +
113
+ "WHY: Hard resets destroy uncommitted work and cannot be undone. This must be user-initiated.\n" +
114
+ "INSTEAD: Ask the user to run this git command manually."
115
+ );
116
+ process.exit(0);
117
+ }
118
+
119
+ if (/(?<!-)\bgit\s+clean\b/.test(cmd) && /-[a-zA-Z]*f/.test(cmd)) {
120
+ deny(
121
+ "BLOCKED: git clean -f detected.\n" +
122
+ "WHY: Force-cleaning the working tree permanently removes untracked files. This must be user-initiated.\n" +
123
+ "INSTEAD: Ask the user to run this git command manually."
124
+ );
125
+ process.exit(0);
126
+ }
127
+
128
+ if (/(?<!-)\bgit\s+(rebase|merge)\b/.test(cmd)) {
129
+ deny(
130
+ "BLOCKED: git rebase/merge detected.\n" +
131
+ "WHY: Rebase and merge rewrite history or combine branches in ways that require user judgment.\n" +
132
+ "INSTEAD: Ask the user to run this git command manually."
133
+ );
134
+ process.exit(0);
135
+ }
136
+
137
+ // Path-scoped blocks -- destructive commands or redirects outside project root
138
+ const winPaths = cmd.match(/(?<![A-Za-z])[A-Za-z]:[/\\][^\s"'|;&)]+/g) || [];
139
+ const unixPaths = cmd.match(/(?<=\s|^|"|')\/[^\s"'|;&)]+/g) || [];
140
+ const allPaths = [...winPaths, ...unixPaths]
141
+ .map((p) => p.trim())
142
+ .filter((p) => !p.startsWith("/dev/"));
143
+
144
+ const outsidePaths = allPaths.filter((p) => isOutside(p));
145
+
146
+ if (outsidePaths.length > 0) {
147
+ const hasDestructiveCmd = /(?<![-])\b(rm|rmdir|del|unlink|mv|cp|touch|mkdir|chmod|chown|truncate|tee|dd|install)\b/.test(cmd);
148
+ const hasInPlaceEdit = /\bsed\b.*\s-i/.test(cmd);
149
+ const hasRedirect = />{1,2}\s*[^\s&>]/.test(cmd);
150
+
151
+ const hasTempPath = outsidePaths.some(
152
+ (p) => /[/\\]tmp[/\\]/i.test(p) || /[/\\]Temp[/\\]/i.test(p)
153
+ );
154
+
155
+ if (hasDestructiveCmd || hasInPlaceEdit || hasRedirect) {
156
+ const instead = hasTempPath
157
+ ? "INSTEAD: Use pipes instead of temp files: cmd 2>&1 | grep pattern not cmd > /tmp/out.txt. All file writes must target paths inside the project."
158
+ : "INSTEAD: Only files within the project directory may be modified. Ask the user to run this command manually if external paths are needed.";
159
+
160
+ deny(
161
+ "BLOCKED: destructive command references path(s) outside the project: " + outsidePaths.join(", ") + ".\n" +
162
+ "WHY: File modifications outside the project boundary are not allowed.\n" +
163
+ instead
164
+ );
165
+ }
166
+ }
167
+ } else {
168
+ // Write, Edit, MultiEdit: check file_path
169
+ const filePath = input.tool_input?.file_path;
170
+ if (filePath && isOutside(filePath)) {
171
+ deny(
172
+ "BLOCKED: " + filePath + " is outside the project.\n" +
173
+ "WHY: [" + (input.tool_name ?? "Unknown") + "] file operations outside the project boundary are not allowed.\n" +
174
+ "INSTEAD: Only files within the project directory may be modified."
175
+ );
176
+ }
177
+ }
178
+ } catch (err) {
179
+ log("ERROR: " + err.message + "\n" + err.stack);
180
+ }
181
+
182
+ process.exit(0);
183
+ `;
23
184
  }
24
185
  function claudeMdTemplate(ctx = {}) {
25
186
  return `<!-- initialized: false -->
@@ -41,8 +202,10 @@ At the start of every session:
41
202
  3. Check installed \`@elevasis/sdk\` template version against \`templateVersion\`
42
203
  in \`elevasis.config.ts\`. If newer, notify and suggest \`/meta update\`.
43
204
  4. If \`.claude/memory/\` does not exist, suggest \`/meta init\`.
44
- 5. If user TypeScript level is beginner (from skills.md) and
205
+ 5. If user Platform Navigation level is none (from skills.md) and
45
206
  \`.claude/memory/tutorial-progress.md\` does not exist, suggest \`/tutorial\`.
207
+ If tutorial-progress.md exists and Phase is not complete, mention that the
208
+ tutorial has more to explore.
46
209
 
47
210
  Do this silently. Do not narrate the steps to the user.
48
211
 
@@ -70,8 +233,10 @@ proactivity -- to their assessed levels.
70
233
  | Interaction guidance | \`reference/developer/interaction-guidance.mdx\` | Unsure how to adapt for a skill combination |
71
234
  | Error history | \`.claude/memory/errors/index.md\` | Debugging errors, checking past fixes |
72
235
  | Command View model | \`reference/deployment/command-view.mdx\` | Deploying or building resources that invoke other resources |
236
+ | Command Center UI reference | \`reference/deployment/command-center-ui.mdx\` | User asks about post-deployment UI or Command Center navigation |
73
237
  | SDK error reference | \`reference/troubleshooting/common-errors.mdx\` | Unknown error not in workspace memory |
74
238
  | Project map | \`docs/project-map.mdx\` | Session start, project orientation |
239
+ | Resource inventory | \`docs/resource-map.mdx\` | Finding a specific resource by name or ID |
75
240
  | Project priorities | \`docs/priorities.mdx\` | Deciding what to work on next |
76
241
  | User profile and skills | \`.claude/memory/profile/skills.md\` | Session start (mandatory) |
77
242
  | Cross-session memory | \`.claude/memory/index.md\` | Session start, recalling past context |${ctx.hasUI ? `
@@ -86,6 +251,7 @@ SDK patterns (imports, source structure, platform tools) are auto-loaded from
86
251
  \`.claude/rules/workspace-patterns.md\`.
87
252
 
88
253
  - Documentation goes in \`docs/\` as \`.mdx\` files
254
+ - Resources are not visible in the Command Center until deployed. Always deploy before directing users to verify in the UI.
89
255
 
90
256
  ### Error Handling
91
257
 
@@ -114,10 +280,10 @@ based on what you find.
114
280
 
115
281
  - Match vocabulary to the user's level. Avoid jargon for beginners;
116
282
  be precise for experts. Define technical terms in parentheses the first time.
117
- - Show complete, working files for users below intermediate programming.
118
- Never show code fragments they can't place.
283
+ - Provide step-by-step UI navigation for users with Platform Navigation below comfortable.
284
+ Reference exact page names and paths until they are oriented.
119
285
  - Explain "why" before "how" for users new to automation.
120
- - For users comfortable with code, focus on SDK-specific patterns.
286
+ - For users comfortable with the platform, focus on SDK-specific patterns and advanced operations.
121
287
  - Leverage domain expertise -- if the user knows sales but not code,
122
288
  ask for business process descriptions and translate.
123
289
  - When growth is observed, note it in the skills.md Growth Log.
@@ -130,9 +296,8 @@ For detailed per-dimension adaptation rules, read
130
296
  | Command | Purpose |
131
297
  | --- | --- |
132
298
  | \`/meta\` | Project lifecycle: init, status, fix, deploy, health |
133
- | \`/docs\` | Documentation lifecycle: create, review, verify |
134
299
  | \`/work\` | Task tracking: create, save, resume, complete |
135
- | \`/tutorial\` | Progressive learning path |
300
+ | \`/tutorial\` | Progressive learning path (7 core lessons + 9 modules) |
136
301
 
137
302
  ## Skills
138
303
 
@@ -178,122 +343,539 @@ Do not store in \`.claude/memory/\`:
178
343
  - If an error pattern recurs 3+ times, promote to Rules above
179
344
  `;
180
345
  }
181
- function claudeDocsCommandTemplate() {
182
- return `# /docs command
346
+ function claudeTutorialCommandTemplate() {
347
+ return `# /tutorial command
183
348
 
184
- You are a documentation assistant for this Elevasis workspace.
349
+ You are a tutorial guide for this Elevasis workspace.
185
350
 
186
351
  ## Context
187
352
 
188
- Read the project's CLAUDE.md and all files in docs/ to understand the project.
189
- Read src/index.ts and the domain directories (src/operations/, src/example/, etc.) to understand the resource definitions.
353
+ Read \`.claude/memory/profile/skills.md\` first. The \`automation\` skill level
354
+ controls which docs you load and which lesson variant you deliver.
190
355
 
191
- ## Operations
356
+ **automation: none**
357
+ - Load from \`reference/concepts/index.mdx\`: Glossary, What is a Workflow,
358
+ Platform Tools Overview only. Skip Zod, Execution Model, Design Decisions.
359
+ - Load \`reference/deployment/command-center-ui.mdx\` for UI-first teaching.
360
+ - Do NOT load \`reference/resources/patterns.mdx\` or
361
+ \`reference/platform-tools/adapters.mdx\` during core lessons.
192
362
 
193
- **No arguments (default):** Review existing docs/ files and suggest improvements.
194
- Identify undocumented resources, missing descriptions, and structural gaps.
363
+ **automation: low-code**
364
+ - Load all sections of \`reference/concepts/index.mdx\`.
365
+ - Load \`reference/resources/patterns.mdx\` with Zapier/Make mapping in mind.
366
+ - Load \`reference/platform-tools/adapters.mdx\` on-demand (when tools are used).
195
367
 
196
- **\`create <page-name>\`:** Create a new documentation page in docs/.
197
- Use the frontmatter schema (title, description, order).
198
- Populate with content based on the resource definitions in src/.
368
+ **automation: custom**
369
+ - Load all docs listed per-lesson and per-module as specified below.
199
370
 
200
- **\`review\`:** Review all docs/ files for accuracy against the actual resource
201
- definitions. Flag mismatches between documented schemas and code.
371
+ Read \`.claude/memory/tutorial-progress.md\` to check current lesson progress.
202
372
 
203
- **\`verify [path]\`:** Cross-reference documentation with the codebase.
204
- Read the specified doc (or all docs if no path), compare claims against actual
205
- code (resource IDs, schema fields, platform tools used), and report
206
- discrepancies. Useful before \`/meta deploy\` to ensure docs are accurate.
207
- `;
208
- }
209
- function claudeTutorialCommandTemplate() {
210
- return `# /tutorial command
373
+ ## Invocation
211
374
 
212
- You are a tutorial guide for this Elevasis workspace.
375
+ \`/tutorial\` -- ALWAYS shows the main menu first. Never silently auto-resumes without giving the user a choice. See ## Menu section for the exact menu format.
213
376
 
214
- ## Context
377
+ ## Menu
215
378
 
216
- Read \`.claude/memory/profile/skills.md\` to adapt lesson pacing and vocabulary.
217
- Read \`.claude/memory/tutorial-progress.md\` to check current lesson progress.
218
- Read \`reference/concepts/index.mdx\` for teaching vocabulary and concept definitions.
379
+ When \`/tutorial\` is invoked:
219
380
 
220
- ## Invocation
381
+ 1. Read \`.claude/memory/tutorial-progress.md\` (if it exists)
382
+ 2. Display the appropriate menu:
383
+
384
+ **No progress (first time):**
385
+
386
+ \`\`\`
387
+ Welcome to the Elevasis Tutorial!
388
+ ==================================
389
+
390
+ What would you like to learn?
391
+
392
+ 1. Orchestration Concepts (Core Path)
393
+ Build workflows step-by-step: data schemas, platform tools,
394
+ multi-step flows, decision points, and production deployment.
395
+ 7 lessons -- estimated 2-3 hours total.
396
+
397
+ 2. Examples & Advanced Modules
398
+ Hands-on deep-dives: human-in-the-loop, scheduling,
399
+ notifications, integrations, LLM, agents, and more.
400
+ 9 standalone modules -- pick any order.
401
+
402
+ 3. Meta-Framework
403
+ Learn the Claude Code context system: /meta, /work,
404
+ rules, memory, and how to customize your workspace.
405
+ 5 lessons -- estimated 1-2 hours total.
406
+
407
+ Pick a number to start, or say "status" to see your progress.
408
+ \`\`\`
409
+
410
+ **With existing progress:**
221
411
 
222
- - \`/tutorial\` -- Resume from current lesson. If no progress exists, start Lesson 1.
223
- - \`/tutorial start\` -- Reset progress and begin from Lesson 1.
224
- - \`/tutorial <number>\` -- Jump to a specific lesson (1-7).
412
+ Show active tracks at the top, then offer resume options alongside new choices. Example:
413
+
414
+ \`\`\`
415
+ Progress: Core Path (Lesson 4/7) | Meta-Framework (MF2/5)
416
+
417
+ 1. Resume Orchestration Concepts (Lesson 4)
418
+ 2. Orchestration Concepts (Core Path -- start over)
419
+ 3. Examples & Advanced Modules
420
+ 4. Resume Meta-Framework (MF2)
421
+ 5. Meta-Framework (start over)
422
+ 6. Show full status
423
+
424
+ Pick a number, or describe what you'd like to learn.
425
+ \`\`\`
426
+
427
+ After user picks:
428
+ - Orchestration Concepts: Resume or start core lesson flow
429
+ - Examples & Advanced Modules: Show module menu (see ## Module Menu)
430
+ - Meta-Framework: Resume or start MF1 (see ## Meta-Framework Track)
431
+ - "status": Display Phase, current position, completion counts
432
+
433
+ ## Progress Logic
434
+
435
+ 1. Read \`.claude/memory/tutorial-progress.md\`
436
+ 2. Show the menu (## Menu section) with progress summary if progress exists
437
+ 3. After user picks a track:
438
+ - **Orchestration Concepts**: If Completed Lessons < 7 -> start/resume at Current Lesson; if 7 complete -> note completion, offer module menu or repeat
439
+ - **Examples & Advanced Modules**: Show module menu (## Module Menu section)
440
+ - **Meta-Framework**: If Current MF Lesson is set -> resume at that lesson; otherwise start MF1
441
+ 4. Track completion: mark the track done in progress file when all lessons/modules complete
442
+ 5. If all three tracks complete -> set Phase to \`complete\`, congratulate, suggest exploring docs/ or /work
225
443
 
226
444
  ## Lesson Flow
227
445
 
228
446
  Each lesson follows this flow:
229
447
  1. Announce lesson title and what they'll learn (1-2 sentences)
230
- 2. Explain the concept (read concepts page, adapt to skill level)
231
- 3. Guide user to build or modify something (show complete code for beginners)
232
- 4. Verify it works (run CLI command, check output)
448
+ 2. Explain the concept (read docs per skill level, adapt to user)
449
+ 3. Guide user to build or modify something (agent writes all code for automation: none)
450
+ 4. Verify it works (Execution Runner is primary for none; CLI + UI are equal for others)
233
451
  5. Celebrate success, record observations in \`.claude/memory/tutorial-progress.md\`
234
452
  6. Ask: "Ready for the next lesson, or want to practice more?"
235
453
 
236
454
  ## Lessons
237
455
 
238
456
  **Lesson 1: Welcome & Orientation**
457
+
458
+ When automation is none:
459
+ Skip the file tour. Start with what Elevasis does for their business -- use analogies
460
+ from \`reference/developer/interaction-guidance.mdx\` (recipe, assembly line, kitchen
461
+ appliance). Explain deployment plainly: "You write the recipe here, then deploy it so
462
+ it's live." Deploy the starter echo workflow (\`elevasis check\` + \`elevasis deploy\`),
463
+ THEN tour the Command Center so the user sees populated pages, not empty ones. Tour:
464
+ Command View (echo node), Execution Runner (run echo from form), Execution Logs (result).
465
+ Observation focus: automation value understanding, Command Center comfort.
466
+
467
+ When automation is low-code or custom:
239
468
  Tour project files: src/index.ts (registry), src/example/echo.ts (starter
240
469
  workflow), src/operations/platform-status.ts (platform API example),
241
470
  elevasis.config.ts, .env, docs/. Explain the execution model.
242
- Verify: run \`elevasis resources\`. Observation focus: cloud deployment model.
471
+ Verify: run \`elevasis resources\`. Then open the Command Center and tour the
472
+ main pages: Command View (resource graph), Execution Runner, Execution Logs.
473
+ Point out the echo workflow node in Command View.
474
+ Observation focus: cloud deployment model, UI navigation comfort.
243
475
 
244
476
  **Lesson 2: Your First Custom Workflow**
477
+
478
+ When automation is none:
479
+ Frame the workflow as "a recipe." Use plain language: "settings" not "config",
480
+ "what data it needs" not "contract", "instructions" not "steps", "where it starts"
481
+ not "entryPoint." Agent writes all code changes. Execution Runner form is PRIMARY
482
+ verification -- show user how to fill the form and run it. CLI is secondary:
483
+ "here's the power user way." Observation focus: recipe-to-result connection, form comfort.
484
+
485
+ When automation is low-code or custom:
245
486
  Modify the echo workflow. Walk through each part: config, contract, steps,
246
487
  entryPoint. Deploy: \`elevasis check\` then \`elevasis deploy\`. Test with
247
- \`elevasis exec echo --input '{"message":"hello"}'\`.
248
- Observation focus: TypeScript syntax comfort.
488
+ \`elevasis exec echo --input '{"message":"hello"}'\`. Then open the Execution
489
+ Runner in the Command Center, find the echo workflow, fill out the form, and
490
+ run it from the UI. Compare the result to the CLI output.
491
+ Observation focus: deployment-to-execution loop, TypeScript syntax comfort.
249
492
 
250
493
  **Lesson 3: Understanding Data (Schemas)**
494
+
495
+ When automation is none:
496
+ Frame as "What information does your automation need?" Each piece becomes a form
497
+ field. Describe types in plain English: text, number, yes/no, a choice from a list.
498
+ NO Zod, no z.string(), no z.infer(), no code shown. Agent reads identity.md goals
499
+ and writes the workflow schema. User fills the form in Execution Runner to verify.
500
+ Observation focus: data-to-form connection, required vs optional understanding.
501
+
502
+ When automation is low-code:
503
+ "Field mapping like Zapier, but with validation." Show Zod types briefly. Demonstrate
504
+ how \`.describe()\` sets the form field label. Build schema based on identity.md goals.
505
+ After deploy, open Execution Runner and point out each field.
506
+ Observation focus: schema-to-form connection, optional fields, types.
507
+
508
+ When automation is custom:
251
509
  Explain schemas in plain English (concepts page). Show common Zod types.
252
510
  Explain \`z.infer\`. Build a new workflow with real-world input schema based
253
- on the user's goals (read .claude/memory/profile/identity.md).
254
- Observation focus: optional fields, types, suggesting own fields.
511
+ on the user's goals (read .claude/memory/profile/identity.md). After deploy,
512
+ open the Execution Runner and show how each Zod field becomes a form control.
513
+ Point out how \`.describe()\` sets the field label.
514
+ Observation focus: schema-to-form connection, optional fields, types.
255
515
 
256
516
  **Lesson 4: Using Platform Tools**
517
+
518
+ When automation is none:
519
+ Frame as "Connecting your automation to a service you already use." Pick ONE
520
+ service from identity.md tools. Agent makes the code edit -- no adapter or
521
+ singleton explanation, no imports shown. Guide credential creation step-by-step
522
+ via Command Center UI (Settings > Credentials). Show where the connection appears
523
+ in Command View after deploy.
524
+ Observation focus: service-connection concept, credential comfort.
525
+
526
+ When automation is low-code or custom:
257
527
  Explain platform tools (concepts page). Browse available tools via
258
528
  reference/platform-tools/index.mdx. Pick a tool based on user's goals.
259
529
  Build: add a tool step using typed adapters (preferred) or platform.call().
260
530
  Show adapter pattern: \`const attio = createAttioAdapter('cred')\`.
261
531
  Show singleton pattern: \`import { scheduler, llm } from '@elevasis/sdk/worker'\`.
262
- Explain credential setup. See reference/platform-tools/adapters.mdx for full API.
263
- Observation focus: credential model, async/await.
532
+ Guide credential creation: for API keys, use the \`creds\` skill or Settings >
533
+ Credentials in the Command Center. For OAuth credentials, the UI is required.
534
+ If using the approval tool, note that pending requests surface in Command Queue.
535
+ See reference/platform-tools/adapters.mdx for full API.
536
+ Observation focus: credential setup (CLI + UI), async/await.
264
537
 
265
538
  **Lesson 5: Multi-Step Workflows**
539
+
540
+ When automation is none:
541
+ Frame as "Step 1 passes its result to Step 2, like a relay race." Command View is
542
+ PRIMARY teaching tool -- show the visual graph before explaining code. Agent builds
543
+ the 2-step workflow. User verifies in Command View (see the two nodes + arrow) and
544
+ Execution Runner (see output flow). Code is secondary.
545
+ Observation focus: relay-race concept, visual graph comprehension.
546
+
547
+ When automation is low-code or custom:
266
548
  Chain steps with StepType.LINEAR. Build a 2-step workflow. Explain data
267
- flow between steps. Deploy and test.
268
- Observation focus: data flow reasoning.
549
+ flow between steps. Deploy and test. Then open the Command View and show the
550
+ relationship edges between resources. Explain how declared relationships map
551
+ to the visual graph.
552
+ Observation focus: data flow reasoning, relationship visualization.
269
553
 
270
554
  **Lesson 6: Decision Points**
555
+
556
+ When automation is none:
557
+ Frame as "If the customer is VIP, do this -- otherwise, do that." No StepType.CONDITIONAL
558
+ jargon -- focus on the concept, not the implementation. Agent adds the condition.
559
+ User tests both paths via Execution Runner, then opens Execution Logs to see which
560
+ path ran. Guide log navigation step-by-step.
561
+ Observation focus: branching concept understanding, log navigation.
562
+
563
+ When automation is low-code or custom:
271
564
  Conditional routing with StepType.CONDITIONAL. Add a condition to the
272
- multi-step workflow from Lesson 5. Test both paths.
273
- Observation focus: branching logic reasoning.
565
+ multi-step workflow from Lesson 5. Test both paths. After testing, open
566
+ Execution Logs in the Command Center, filter by the resource, and show how
567
+ each path appears in the log detail (step trace, input/output).
568
+ Observation focus: branching logic reasoning, execution log interpretation.
274
569
 
275
570
  **Lesson 7: Going to Production**
276
- Change status from dev to production. Show monitoring: elevasis executions,
277
- elevasis execution. Cover error handling: try/catch, ExecutionError,
278
- PlatformToolError. Suggest next steps based on goals.
279
- Observation focus: readiness for independent development.
571
+
572
+ When automation is none:
573
+ Frame as "draft vs live" not "dev vs production." Error handling: "when something
574
+ goes wrong with your data" / "when a connected service fails" -- no type names.
575
+ Task Scheduler and Knowledge Base stay as-is (UI-friendly already). Open Deployments
576
+ page to show version is active.
577
+ Observation focus: draft/live concept, readiness for independent Command Center use.
578
+
579
+ When automation is low-code or custom:
580
+ Change status from dev to production. Cover error handling: try/catch,
581
+ ExecutionError, PlatformToolError. Create a schedule in Task Scheduler (use
582
+ Recurring type for a cron schedule). If docs/ has pages, show Knowledge Base.
583
+ Open Deployments page to confirm the latest version is active. Show CLI
584
+ monitoring: elevasis executions, elevasis execution. Suggest next steps.
585
+ Observation focus: readiness for independent operation (CLI + UI).
586
+
587
+ ## Module Menu
588
+
589
+ Fixed module order: hitl, schedules, notifications, integrations, workflows,
590
+ composition, llm, agents, error-handling.
591
+
592
+ Show the next 2-3 uncompleted modules from the list. Format:
593
+
594
+ "Core path complete! Here are your next modules:"
595
+ 1. <Title> -- <one-line description>
596
+ 2. <Title> -- <one-line description>
597
+ 3. <Title> -- <one-line description>
598
+ "Pick a number to start, or say 'show more' to see additional modules."
599
+
600
+ If all 9 modules are complete -> set Phase to \`complete\`, congratulate.
601
+
602
+ ## Module Flow
603
+
604
+ Each module follows this flow:
605
+ 1. Announce module title and what they'll build (1-2 sentences)
606
+ 2. Read the listed SDK reference docs for teaching context
607
+ 3. Guide user to build a resource exercising the module's concepts
608
+ 4. Verify it works (CLI + Command Center where applicable)
609
+ 5. Record observations in \`.claude/memory/tutorial-progress.md\`
610
+ 6. Return to module menu (show next uncompleted modules)
611
+
612
+ ## Modules
613
+
614
+ **Module: hitl -- Human-in-the-Loop**
615
+ Read: \`reference/deployment/command-center-ui.mdx\` (Command Queue section).
616
+ Build: Add an approval gate using \`approval.requestApproval()\`. Test full lifecycle:
617
+ trigger, see pending in Command Queue, approve/reject, observe resume.
618
+ Key concepts: approval adapter, pending state, Command Queue UI, resume on decision.
619
+ Verify: Trigger workflow, open Command Queue, approve, confirm completion.
620
+
621
+ **Module: schedules -- Task Scheduling**
622
+ Read: \`reference/deployment/command-center-ui.mdx\` (Task Scheduler section).
623
+ Build: Create all three schedule types (Recurring cron, Relative delay, Absolute
624
+ datetime). Use \`scheduler\` adapter for in-workflow scheduling.
625
+ Key concepts: schedule types, cron syntax, scheduler adapter, Task Scheduler UI.
626
+ Verify: Create each type in Task Scheduler, confirm scheduled execution in Execution Logs.
627
+
628
+ **Module: notifications -- Notification System**
629
+ Read: \`reference/platform-tools/adapters.mdx\` (notifications, email singletons).
630
+ Build: Add notification and email steps to a workflow. Send alerts on completion.
631
+ Key concepts: notifications singleton, email singleton, alert patterns.
632
+ Verify: Run workflow, check notification in Command Center, confirm email received.
633
+
634
+ **Module: integrations -- Real-World Integrations**
635
+ Read: \`reference/platform-tools/index.mdx\`, \`reference/platform-tools/adapters.mdx\`,
636
+ \`reference/security/credentials.mdx\`.
637
+ Build: Pick a real integration adapter based on user's goals (read \`identity.md\`).
638
+ Set up credential (OAuth via UI, API key via CLI). Build end-to-end integration workflow.
639
+ Key concepts: adapter pattern, credential scoping, error handling for external calls.
640
+ Verify: Run workflow with real credential, confirm external service call, test error
641
+ handling with invalid credential.
642
+
643
+ **Module: workflows -- Advanced Workflows**
644
+ Read: \`reference/resources/patterns.mdx\` (execution store, logging, organizing).
645
+ Build: Refactor an existing workflow to use \`context.store\` for cross-step data,
646
+ \`context.logger\` for structured logging, and organize into a domain directory.
647
+ Add advanced schema patterns (nested objects, arrays, optional fields).
648
+ Key concepts: context.store, context.logger, domain organization, schema depth.
649
+ Verify: Run workflow, confirm store values in step output, check logs in Execution Logs.
650
+
651
+ **Module: composition -- Resource Composition**
652
+ Read: \`reference/deployment/command-view.mdx\`, \`reference/resources/patterns.mdx\`.
653
+ Build: Create two workflows where the first triggers the second using
654
+ \`execution.trigger()\`. Declare the relationship.
655
+ Key concepts: execution.trigger, relationship declarations, Command View graph edges.
656
+ Verify: Deploy, see relationship edge in Command View, trigger parent and confirm
657
+ child executes.
658
+
659
+ **Module: llm -- LLM Integration**
660
+ Read: \`reference/platform-tools/adapters.mdx\` (llm singleton).
661
+ Build: Create a workflow step using \`llm.generate()\` with structured output.
662
+ Experiment with model selection and temperature.
663
+ Key concepts: llm singleton, structured output, model selection, temperature.
664
+ Verify: Run workflow, compare outputs with different settings, confirm structured output.
665
+
666
+ **Module: agents -- AI Agents**
667
+ Read: \`reference/framework/agent.mdx\`.
668
+ Build: Create an agent definition with tools. Configure LLM tool calling.
669
+ Compare agent vs workflow for a task.
670
+ Key concepts: agent definition, tool registration, LLM tool calling, execution trace.
671
+ Verify: Run agent with \`elevasis exec\`, review tool call trace in Execution Logs.
672
+
673
+ **Module: error-handling -- Error Handling Mastery**
674
+ Read: \`reference/resources/patterns.mdx\` (error handling),
675
+ \`reference/troubleshooting/common-errors.mdx\`.
676
+ Build: Create a workflow demonstrating all three error types. Add try/catch,
677
+ \`context.logger\`, and error recovery.
678
+ Key concepts: ExecutionError, PlatformToolError, ToolingError, recovery patterns.
679
+ Verify: Trigger each error type, confirm messages in Execution Logs with correct
680
+ categorization.
681
+
682
+ ## Meta-Framework Track
683
+
684
+ The Meta-Framework track teaches you how the Claude Code workspace works -- the commands,
685
+ rules, memory system, and customization model. It is independent of the core path and
686
+ can be taken in any order.
687
+
688
+ **MF1: The Agent Framework -- How This Workspace Works**
689
+
690
+ When automation is none:
691
+ "This workspace comes with a built-in assistant that knows your project, your tools,
692
+ and your goals. Let me show you how it's set up." Open CLAUDE.md and explain in
693
+ plain terms: it's the agent's instruction sheet. Point out the commands in the
694
+ Commands table. Show /meta, /tutorial, /work. Explain the creds skill as
695
+ "the assistant automatically helps when you mention API keys." Tour the memory folder
696
+ at a high level -- "this is where the agent stores what it learns about your project."
697
+ Verify: Ask the user a question about their business goal and show how the agent
698
+ references their profile in the answer.
699
+ Observation focus: agent-as-assistant concept, CLAUDE.md as instruction sheet.
700
+
701
+ When automation is low-code:
702
+ Read CLAUDE.md and walk through each section. Explain: what the agent reads on
703
+ session start, how the navigation table works, what the Skills section means.
704
+ Explain the four commands briefly. Show that the agent has memory: open
705
+ \`.claude/memory/profile/skills.md\` and show their own profile -- "every session,
706
+ the agent reads this and adapts." Explain the initialized flag.
707
+ Verify: Run /meta to see project status.
708
+ Observation focus: memory system concept, session initialization flow.
709
+
710
+ When automation is custom:
711
+ Read CLAUDE.md in full. Explain the session initialization sequence: CLAUDE.md ->
712
+ navigation table -> memory files -> context loading. Walk through: Commands section
713
+ (4 commands + creds skill), Rules section (auto-loaded based on file paths), Skills
714
+ section (auto-triggered by content patterns). Point out the initialized flag and
715
+ explain how /meta init set it.
716
+ Verify: Run /meta to see project status; observe which fields it reports.
717
+ Observation focus: initialization model, command-vs-rule-vs-skill distinction.
718
+
719
+ **MF2: The /meta Command -- Project Lifecycle**
720
+
721
+ When automation is none:
722
+ "Think of /meta as your project dashboard -- it shows what's healthy and what needs
723
+ attention." Run /meta (no arguments) and narrate the output in plain language: what
724
+ each field means. Explain /meta fix as "the agent tidies up and applies updates."
725
+ Explain /meta deploy as "the agent publishes your changes in one step." Briefly note
726
+ /meta health shows what happened when something goes wrong.
727
+ Verify: Run /meta (no arguments). Narrate the output together.
728
+ Observation focus: project lifecycle concept, dashboard reading.
729
+
730
+ When automation is low-code:
731
+ Show all /meta operations with their purpose. Map to familiar concepts: /meta fix is
732
+ like "repair this Zap" in Zapier; /meta deploy is a one-command publish pipeline.
733
+ Walk through the /meta (no-args) output: template version (SDK template your workspace
734
+ uses), SDK version (installed package), profile summary, drift check.
735
+ Verify: Run /meta and interpret each field together.
736
+ Observation focus: deploy pipeline understanding, version tracking.
737
+
738
+ When automation is custom:
739
+ Read \`.claude/commands/meta.md\`. Walk through each operation: init (first-run setup
740
+ with assessment), (no-args) (status dashboard), fix (drift repair + SDK upgrade +
741
+ rules health), deploy (7-step pipeline: check, typecheck, docs, git, deploy,
742
+ project-map, verify), health (runtime diagnostics). Explain the merge strategy for
743
+ CLAUDE.md and commands. Note the template access model: templates read from
744
+ @elevasis/sdk/templates subpath.
745
+ Verify: Run /meta to see project status. Identify what a version mismatch looks like.
746
+ Observation focus: full lifecycle coverage, pipeline internals.
747
+
748
+ **MF3: /work -- Task Lifecycle**
749
+
750
+ When automation is none:
751
+ "You can ask the assistant to track work across conversations. When you start something
752
+ complex, use /work create to save your place. Next session, /work resume picks up where
753
+ you left off." Walk through the concept without deep command details. Show docs/ -- explain
754
+ it's where project notes live.
755
+ Verify: Create a task with \`/work create "practice task"\`, then run /work to see it listed.
756
+ Observation focus: persistence concept, cross-session continuity.
757
+
758
+ When automation is low-code:
759
+ Show /work operations: create (task doc with frontmatter + sections), save (updates
760
+ Progress + Resume Context), resume (loads context for next session).
761
+ Explain how task docs persist: they're workspace files, not memory -- they survive
762
+ session compaction.
763
+ Verify: Create a task with \`/work create "practice task"\`, run /work save, inspect the file.
764
+ Observation focus: task tracking workflow, doc creation pattern.
765
+
766
+ When automation is custom:
767
+ Read \`.claude/commands/work.md\`. Full coverage:
768
+ /work create (kebab-case filename, frontmatter with status, Objective/Plan/Progress/
769
+ Resume Context sections), /work save (Progress + Resume Context update), /work resume
770
+ (multiple-task disambiguation), /work complete (moves to final location).
771
+ Explain how Resume Context serves as the session handoff artifact.
772
+ Verify: Create a task doc, save progress, inspect the generated file structure.
773
+ Observation focus: task doc anatomy, resume context as handoff pattern.
774
+
775
+ **MF4: Rules, Memory, and Customization**
776
+
777
+ When automation is none:
778
+ "The assistant has a set of reminders specific to your project. Over time, when it
779
+ makes the same mistake 3 times, you can tell it to always remember that rule -- it
780
+ lives in a file so the rule sticks across conversations."
781
+ Show \`.claude/rules/workspace-patterns.md\` without technical detail. Explain: "This
782
+ is where YOUR project's rules go. The other rule files are updated automatically by
783
+ SDK releases."
784
+ Verify: Open \`.claude/rules/workspace-patterns.md\` and read the current content together.
785
+ Observation focus: customization concept, owned vs managed files.
786
+
787
+ When automation is low-code:
788
+ Show the \`.claude/rules/\` directory. Explain the two types: sdk-patterns.md (MANAGED --
789
+ updated by elevasis update) and workspace-patterns.md (INIT_ONLY -- yours to edit).
790
+ Explain path-scoping briefly: "These rules only activate when the agent is working on
791
+ certain file types." Show an example rule with WRONG/RIGHT pattern. Explain error
792
+ promotion: if something goes wrong 3+ times, add it here.
793
+ Verify: Read \`.claude/rules/workspace-patterns.md\`. Note the "When to Add a Rule" section.
794
+ Observation focus: two-tier ownership model, rule format.
795
+
796
+ When automation is custom:
797
+ Read \`.claude/rules/sdk-patterns.md\` and \`.claude/rules/workspace-patterns.md\`.
798
+ Explain MANAGED vs INIT_ONLY lifecycle. Show rule frontmatter structure (paths: for
799
+ auto-loading by the agent). Explain the memory system layout: \`.claude/memory/\`
800
+ (index.md root, profile/ subdirectory, errors/ for promoted issues,
801
+ tutorial-progress.md). Explain error promotion: 3+ recurrences -> rule in
802
+ workspace-patterns.md. Walk through how to add a new rule.
803
+ Verify: Read \`.claude/rules/workspace-patterns.md\`. Add a sample rule entry together.
804
+ Observation focus: MANAGED vs INIT_ONLY lifecycle, rule authoring, memory layout.
805
+
806
+ **MF5: Advanced -- Template Lifecycle and Extending**
807
+
808
+ When automation is none:
809
+ "When Elevasis SDK releases updates, the assistant can apply them to your workspace
810
+ automatically. You don't have to redo your customizations." Explain /meta fix as
811
+ the command that applies updates. Skip technical file classification details.
812
+ Show \`docs/project-map.mdx\` briefly: "This is an auto-generated map of everything
813
+ in your project -- the agent uses it for navigation."
814
+ Verify: Run /meta fix (or explain what it would do). Check \`docs/project-map.mdx\`.
815
+ Next steps: point to reference docs in docs/, encourage using /work for new tasks.
816
+ Observation focus: update model concept, project map as navigation aid.
817
+
818
+ When automation is low-code:
819
+ Explain MANAGED (auto-updated by elevasis update) vs INIT_ONLY (set once, yours).
820
+ Show how /meta fix applies SDK updates with conflict handling: "If a file changed,
821
+ it shows you both versions and lets you decide."
822
+ Show \`docs/project-map.mdx\` and explain what it contains: resources, commands,
823
+ rules, memory index. Note that deploy auto-regenerates it.
824
+ Verify: Read \`elevasis.config.ts\` templateVersion. Compare to the running SDK version from /meta.
825
+ Observation focus: update workflow, project map freshness.
826
+
827
+ When automation is custom:
828
+ Read \`elevasis.config.ts\` for the current templateVersion. Read \`docs/project-map.mdx\`.
829
+ Explain the full template lifecycle: init (writes all files with classification),
830
+ update (applies MANAGED changes, flags conflicts, preserves INIT_ONLY), fix (detects
831
+ drift, offers SDK upgrade, runs full repair). Explain conflict handling: read current
832
+ file, read template from @elevasis/sdk/templates, merge preserving customizations.
833
+ Explain the project map: auto-generated by deploy, contains resource inventory,
834
+ command list, rule list, memory index.
835
+ Next steps: explore reference docs, use /work for complex tasks, build custom rules.
836
+ Verify: Compare elevasis.config.ts templateVersion with output of /meta. Identify any drift.
837
+ Observation focus: full template lifecycle, conflict resolution pattern.
280
838
 
281
839
  ## Adaptation Rules
282
840
 
283
- - If user is intermediate/advanced (from skills.md), condense explanations
284
- - If user struggles, slow down with more plain-English explanation
285
- - If user is fast, acknowledge and offer to skip ahead
841
+ **automation: none**
842
+ Use the non-technical variant for each lesson. Agent writes all code -- user
843
+ never types code. User verifies visually (Execution Runner, Command View, Logs).
844
+ Avoid all jargon; use analogies. Execution Runner is the primary verification tool.
845
+ Always deploy before directing the user to the Command Center.
846
+
847
+ **automation: low-code**
848
+ Map concepts to Zapier/Make equivalents. Show code with plain-English explanations.
849
+ Execution Runner and CLI are equal verification tools. Show Zod types with labels.
850
+
851
+ **automation: custom**
852
+ Full technical content. Code-first. CLI and UI are equal. Condense explanations
853
+ for intermediate/advanced users.
854
+
855
+ **General rules (all levels)**
856
+ - If user is fast, acknowledge and offer to skip ahead within a lesson
286
857
  - After each lesson, update \`.claude/memory/tutorial-progress.md\`
287
858
  - If user demonstrates a level change, promote to skills.md Growth Log
859
+ - After completing a module, return to the module menu
860
+ - Adapt module depth to skill level as with lessons
288
861
 
289
862
  ## Progress Format
290
863
 
291
864
  Store in \`.claude/memory/tutorial-progress.md\`:
292
- - Current Lesson number
865
+ - Phase (core | modules | meta-framework | complete)
866
+ - Current Lesson number (during core phase)
867
+ - Current Module (module id during modules phase)
868
+ - Current MF Lesson (MF1-MF5, during meta-framework phase)
293
869
  - Started and Last Session dates
294
870
  - Completed Lessons table (lesson, title, completed, duration)
295
- - Capability Observations table (lesson, observation)
871
+ - Completed Modules table (module, title, completed, duration)
872
+ - Completed MF Lessons table (lesson, title, completed, notes)
873
+ - Capability Observations table (lesson/module, observation) -- prefix L# for lessons, M:<id> for modules, MF# for meta-framework lessons
296
874
  - Assessment Notes (bullet points)
875
+
876
+ Backward-compatible: missing Phase is inferred from lesson count;
877
+ missing Completed Modules is treated as empty;
878
+ missing Completed MF Lessons is treated as empty.
297
879
  `;
298
880
  }
299
881
  function claudeMetaCommandTemplate() {
@@ -318,10 +900,17 @@ by the \`<!-- initialized: false -->\` flag in CLAUDE.md, or run manually.
318
900
  Run \`pnpm install\`. Wait for completion. Report any errors.
319
901
 
320
902
  2. **Setup environment**
321
- Check if \`.env\` has \`ELEVASIS_API_KEY\` set.
322
- If not, ask the user for their API key and write it to \`.env\`.
323
- Validate the key works: run \`elevasis resources\` (should return empty list,
324
- not an auth error).
903
+ Read \`.env\`. It should contain only a single line: \`ELEVASIS_API_KEY=\`.
904
+ If \`ELEVASIS_API_KEY\` is empty or missing, ask the user: "What is your
905
+ Elevasis API key?" When the user provides it, write \`.env\` with exactly:
906
+ \`\`\`
907
+ ELEVASIS_API_KEY=<value they provided>
908
+ \`\`\`
909
+ No other keys (no \`NODE_ENV\`, no extras). The \`.env\` file must contain
910
+ only \`ELEVASIS_API_KEY\`.
911
+ Validate the key works: run \`elevasis resources\` (should return an empty
912
+ list, not an auth error). If auth fails, tell the user their key appears
913
+ invalid and ask them to check it in the Elevasis dashboard.
325
914
 
326
915
  3. **Competency Assessment**
327
916
  Ask these questions to build the user's profile:
@@ -331,16 +920,11 @@ by the \`<!-- initialized: false -->\` flag in CLAUDE.md, or run manually.
331
920
  - "What do you want to automate with Elevasis?"
332
921
  - "Which tools does your team already use?" (email, CRM, spreadsheets, etc.)
333
922
 
334
- Competency (2-3 questions with conditional skipping):
335
- - "Have you written code before? If so, what kind?"
336
- No code -> programming: none, skip next question
337
- HTML/CSS/Excel -> programming: minimal, skip next question
338
- Scripts/websites -> programming: intermediate, ask next question
339
- Production apps -> programming: advanced, ask next question
340
- - (Only if scripts+) "Have you used TypeScript or a typed language?"
341
- No -> typescript: none
342
- Read it / used typed language -> typescript: exposure
343
- Written TypeScript projects -> typescript: proficient
923
+ Competency (2 questions):
924
+ - "Have you used the Elevasis Command Center before?"
925
+ Never used it -> platformNavigation: none
926
+ Explored it / know the main sections -> platformNavigation: oriented
927
+ Use it regularly -> platformNavigation: comfortable
344
928
  - "Have you used automation tools? (Zapier, Make, cron jobs, scripts)"
345
929
  No -> automation: none
346
930
  Zapier/Make flows -> automation: low-code
@@ -368,8 +952,8 @@ by the \`<!-- initialized: false -->\` flag in CLAUDE.md, or run manually.
368
952
  6. **Report**
369
953
  Summary of what was set up. Suggest next steps based on goals.
370
954
 
371
- If the user's TypeScript level is beginner or automation level is new,
372
- suggest /tutorial start: "I recommend starting with /tutorial -- it walks
955
+ If the user's Platform Navigation level is none or automation level is none,
956
+ suggest /tutorial: "I recommend starting with /tutorial -- it walks
373
957
  you through building workflows step by step, at your own pace."
374
958
 
375
959
  7. **Update flag**
@@ -399,8 +983,19 @@ Detect and repair all drift. Optionally upgrades the SDK first.
399
983
  1. **Missing managed files:** Regenerate from templates
400
984
  2. **Gitignore drift:** Append missing entries
401
985
  3. **CLAUDE.md sections:** Add missing sections in correct position
402
- 4. **Memory structure:** Verify index consistency
403
- 5. **Doc cross-references:** Scan for broken links
986
+ 4. **Memory structure:** Create base structure if missing, then verify index consistency.
987
+ If \`.claude/memory/\` does not exist or is empty:
988
+ - Create \`memory/index.md\` (root index with placeholder entries)
989
+ - Create \`memory/errors/index.md\` (error category summary, empty tables)
990
+ - Create \`memory/errors/deploy.md\`, \`memory/errors/runtime.md\`, \`memory/errors/typescript.md\`
991
+ If memory exists, verify: every file referenced in an index exists; every file
992
+ without an index entry gets one added; broken references are removed.
993
+ 5. **Documentation verification:** For each file in docs/:
994
+ a. Cross-reference claims against src/ code (resource IDs, schema fields, platform tools used)
995
+ b. Verify file path references point to real files
996
+ c. Flag mismatches between documented schemas and actual resource definitions
997
+ d. Check for undocumented resources (resources in src/ without docs coverage)
998
+ e. Report discrepancies with suggested fixes
404
999
  6. **Settings consistency:** Verify expected fields
405
1000
  7. **Rules health:** Scan \`memory/errors/\` -- flag any entry that has recurred
406
1001
  3+ times and is not yet in \`.claude/rules/workspace-patterns.md\`.
@@ -452,6 +1047,421 @@ The agent reads current templates from the installed SDK:
452
1047
  \`@elevasis/sdk/templates\` subpath exports all template functions.
453
1048
  `;
454
1049
  }
1050
+ function claudeWorkCommandTemplate() {
1051
+ return `# /work command
1052
+
1053
+ You are a task tracking assistant for this Elevasis workspace. \`/work\` is the primary command for managing all work and projects.
1054
+
1055
+ ## Context
1056
+
1057
+ Read \`docs/priorities.mdx\` if it exists for current priorities.
1058
+ Scan \`docs/in-progress/\` recursively for \`.mdx\` files with \`status\` frontmatter.
1059
+
1060
+ ## Directory Structure
1061
+
1062
+ Task docs live in \`docs/in-progress/\`. Organize intelligently:
1063
+
1064
+ - **Small standalone tasks**: \`docs/in-progress/<slug>.mdx\`
1065
+ - **Multi-file tasks**: \`docs/in-progress/<slug>/index.mdx\` (+ supporting docs)
1066
+ - **Related tasks**: group under the same directory
1067
+
1068
+ When scanning, treat \`index.mdx\` as the primary task doc for a directory.
1069
+
1070
+ ## Status Values
1071
+
1072
+ Enforce exactly three values in frontmatter: \`planned\`, \`in-progress\`, \`complete\`.
1073
+
1074
+ ## Operations
1075
+
1076
+ ### No arguments (default) -- List and Pick
1077
+
1078
+ 1. Scan \`docs/in-progress/\` recursively for \`.mdx\` files with \`status\` frontmatter
1079
+ 2. For directories, read \`index.mdx\` as the primary task doc
1080
+ 3. Display a numbered list sorted by status (\`in-progress\` first, then \`planned\`, then \`complete\`):
1081
+
1082
+ \`\`\`
1083
+ Active Tasks
1084
+ ============
1085
+
1086
+ 1. [in-progress] SDK Adapter Migration
1087
+ Last saved: 2026-03-02 | Step 3/5: Building factory adapters
1088
+
1089
+ 2. [planned] Email Template System
1090
+ Created: 2026-03-01 | Not started
1091
+
1092
+ 3. [complete] CRM Integration
1093
+ Completed: 2026-03-03
1094
+
1095
+ Pick a task by number or name to resume, or say:
1096
+ - "create" to start new work
1097
+ - "complete <name>" to finish a task
1098
+ \`\`\`
1099
+
1100
+ 4. Cross-reference with \`docs/priorities.mdx\` if it exists
1101
+ 5. When the user picks a number or describes a task in natural language, auto-invoke the **resume** flow on that task
1102
+ 6. If no tasks found, suggest \`/work create\`
1103
+
1104
+ ### \`create [description]\`
1105
+
1106
+ Guided task creation with interview:
1107
+
1108
+ 1. If no description given, ask: "What are you trying to accomplish?"
1109
+ 2. Ask 2-3 focused questions:
1110
+ - "What does success look like?" (acceptance criteria)
1111
+ - "Is this related to any existing work?" (scan \`docs/in-progress/\` and \`docs/\` for related topics)
1112
+ - "Do we need to investigate anything first, or is the path clear?" (suggest investigation if needed)
1113
+ 3. Determine directory placement:
1114
+ - Scan \`docs/in-progress/\` for existing directories related to the topic
1115
+ - If related to existing directory, create as a file within it
1116
+ - If new concept that may grow, create \`docs/in-progress/<slug>/index.mdx\`
1117
+ - If small/standalone, create \`docs/in-progress/<slug>.mdx\`
1118
+ 4. Create the doc with \`status: planned\` and structured sections:
1119
+
1120
+ \`\`\`yaml
1121
+ ---
1122
+ title: {Task Title}
1123
+ description: {Concise description}
1124
+ status: planned
1125
+ ---
1126
+ \`\`\`
1127
+
1128
+ Sections: Objective (what and why), Plan (numbered steps), Progress (per-step tracking with PENDING markers), Resume Context (current state, key docs, "To continue" prompt).
1129
+
1130
+ 5. Update \`docs/priorities.mdx\` if it exists
1131
+ 6. Report what was created with location and step count
1132
+
1133
+ ### \`save\`
1134
+
1135
+ Update the current task doc's Progress and Resume Context:
1136
+
1137
+ 1. Identify the current task from conversation context (which in-progress doc was loaded/discussed)
1138
+ 2. If not working on a tracked task, list available docs and ask which to save to, or offer to create a new one
1139
+ 3. Update Progress section:
1140
+ - Mark completed steps as \`COMPLETE\` with: what was done, key decisions, files changed
1141
+ - Mark current step as \`IN PROGRESS\` with current state
1142
+ - Leave future steps as \`PENDING\`
1143
+ 4. Update Resume Context section with:
1144
+ - Current State ({today's date}): summary of accomplishments and next steps
1145
+ - Files Modified: table of file paths and descriptions of changes
1146
+ - Key docs to read on resume: file paths with why they matter
1147
+ - To continue: copy-pasteable prompt for the next session
1148
+ 5. Set \`status\` appropriately (\`in-progress\` if ongoing, \`complete\` if all steps done)
1149
+ 6. Report: task title, status, completed steps count, last step, and the resume command
1150
+
1151
+ ### \`resume [name-or-number]\`
1152
+
1153
+ Resume in-progress work. Designed for non-technical users who may not know file paths.
1154
+
1155
+ **Resolution order:**
1156
+ 1. If a number is given (e.g., \`/work resume 2\`), map to the numbered list from the default list operation
1157
+ 2. If a name/keyword is given, substring match against task titles and filenames in \`docs/in-progress/\`
1158
+ 3. If no argument, scan for \`status: in-progress\` docs -- if one found, use it; if multiple, list and ask
1159
+ 4. If multiple matches, list them and ask which to resume
1160
+
1161
+ **Resume flow:**
1162
+ 1. Read the target task doc
1163
+ 2. Parse the Resume Context section
1164
+ 3. Load key docs listed in "Key docs to read on resume" in parallel
1165
+ 4. Quick verify: check that referenced files exist (Glob), report warnings for missing files
1166
+ 5. Present resume summary:
1167
+
1168
+ \`\`\`
1169
+ Resuming: {task title}
1170
+ ========================
1171
+
1172
+ Last completed: Step {N}: {title}
1173
+ Next: Step {M}: {title}
1174
+
1175
+ Key context loaded:
1176
+ - {doc 1}
1177
+ - {doc 2}
1178
+
1179
+ Ready to continue. {Copy of "To continue" prompt}
1180
+ \`\`\`
1181
+
1182
+ ### \`complete [name]\`
1183
+
1184
+ Mark task complete, clean up, and move to permanent docs:
1185
+
1186
+ 1. Resolve target (same as resume: number, name, or scan for \`status: complete\`)
1187
+ 2. **Validate readiness:** Check that all plan steps are marked COMPLETE. If not, warn and ask for confirmation.
1188
+ 3. **Clean up the doc:**
1189
+ - Strip \`## Resume Context\` section entirely (header through next \`##\` or EOF)
1190
+ - Strip progress markers: \`COMPLETE\`, \`IN PROGRESS\`, \`PENDING\` from step headings
1191
+ - Remove steps still marked PENDING entirely (header + body) -- they were never done
1192
+ - Remove \`status\` from frontmatter (keep \`title\` and \`description\`)
1193
+ - Target 200-400 lines; flag if result exceeds 500 lines
1194
+ 4. **Determine destination:**
1195
+ - Scan \`docs/\` (excluding \`docs/in-progress/\`) for existing directories related to this work
1196
+ - If a related directory exists, propose merging into it
1197
+ - If no related directory, propose \`docs/<slug>/\` or \`docs/<slug>.mdx\`
1198
+ - Present the proposed destination and ask user to confirm
1199
+ 5. **Move the doc(s):**
1200
+ - Single file: move from \`docs/in-progress/\` to destination
1201
+ - Directory: move entire directory
1202
+ 6. **Verify and report:**
1203
+ - Confirm destination exists, source removed
1204
+ - Check no leftover \`status:\` or \`## Resume Context\` in moved files
1205
+ - Update \`docs/priorities.mdx\` if it exists
1206
+ - Report: task title, cleanup stats (lines before/after), destination path
1207
+
1208
+ ## Completion Suggestions
1209
+
1210
+ When the agent observes that all plan steps for a task are marked COMPLETE and the user seems to be moving on, proactively suggest: "All steps for '{task}' are complete. Run \`/work complete\` to finalize it."
1211
+ `;
1212
+ }
1213
+ function claudeCredsSkillTemplate() {
1214
+ return `---
1215
+ name: creds
1216
+ description: "Credential management assistant. TRIGGER when: user mentions credentials, API keys, secrets, webhook secrets, or asks to set up integrations that need authentication. DO NOT TRIGGER when: user is discussing code that references credentials without needing to manage them."
1217
+ ---
1218
+
1219
+ # Credential Management
1220
+
1221
+ You are a credential management assistant for this Elevasis workspace.
1222
+
1223
+ ## Context
1224
+
1225
+ Credentials are stored encrypted (AES-256-GCM) on the Elevasis platform and scoped to your
1226
+ organization. They are used by workflows and agents at runtime via \`platform.getCredential()\`
1227
+ or the \`credential:\` field on tool steps.
1228
+
1229
+ The SDK CLI (\`elevasis-sdk creds\`) manages credentials via API key authentication.
1230
+ Your \`ELEVASIS_API_KEY\` in \`.env\` determines the organization.
1231
+
1232
+ ## Credential Types
1233
+
1234
+ | Type | Value Format | Example Providers |
1235
+ | --- | --- | --- |
1236
+ | \`api-key\` | \`{"apiKey": "sk-..."}\` | Stripe, Resend, Apify, Attio, Instantly |
1237
+ | \`webhook-secret\` | \`{"signingSecret": "whsec_..."}\` | Cal.com, Stripe webhooks |
1238
+ | \`trello\` | \`{"apiKey": "...", "token": "..."}\` | Trello |
1239
+ | \`oauth\` | N/A (browser flow only) | Notion, Google Sheets, Dropbox |
1240
+
1241
+ OAuth credentials **cannot** be created via CLI. Redirect the user to the Command Center UI.
1242
+
1243
+ ## Naming Rules
1244
+
1245
+ - Lowercase letters, digits, and hyphens only (\`[a-z0-9-]\`)
1246
+ - No consecutive hyphens (\`--\`)
1247
+ - 1-100 characters
1248
+ - Convention: \`{org}-{provider}\` (e.g., \`tester-stripe-key\`, \`my-project-resend\`)
1249
+
1250
+ ## Operations
1251
+
1252
+ **No arguments (default):** Show this reference and list credentials.
1253
+
1254
+ **\`list\`:** List all credentials for the organization.
1255
+ \`\`\`bash
1256
+ elevasis-sdk creds list
1257
+ \`\`\`
1258
+ Display the output. Note which are \`oauth\` (not modifiable via CLI).
1259
+
1260
+ **\`create\`:** Guided credential creation flow:
1261
+ 1. Ask credential type (\`api-key\`, \`webhook-secret\`, or \`trello\`). Not \`oauth\`.
1262
+ 2. Ask credential name. Validate naming rules before proceeding.
1263
+ 3. Ask the user to paste the credential value directly in chat.
1264
+ - For \`api-key\`: ask for the API key, construct \`{"apiKey": "..."}\`
1265
+ - For \`webhook-secret\`: ask for the signing secret, construct \`{"signingSecret": "..."}\`
1266
+ - For \`trello\`: ask for API key AND user token, construct \`{"apiKey": "...", "token": "..."}\`
1267
+ 4. Pipe to CLI: \`echo '{"apiKey":"..."}' | elevasis-sdk creds create --name {name} --type {type}\`
1268
+ 5. Confirm success. **NEVER echo the credential value back.**
1269
+
1270
+ **\`update\`:** Update credential value:
1271
+ 1. Run \`elevasis-sdk creds list\` to confirm the credential exists.
1272
+ 2. Ask the user to paste the new value.
1273
+ 3. Pipe to CLI: \`echo '{"apiKey":"..."}' | elevasis-sdk creds update {name}\`
1274
+ 4. Confirm success. **NEVER echo the value.**
1275
+
1276
+ **\`rename\`:** Rename a credential:
1277
+ 1. Run \`elevasis-sdk creds list\` to confirm it exists.
1278
+ 2. Ask for the new name. Validate naming rules.
1279
+ 3. Run: \`elevasis-sdk creds rename {name} --to {newName}\`
1280
+
1281
+ **\`delete\`:** Delete a credential:
1282
+ 1. Run \`elevasis-sdk creds list\` to confirm it exists.
1283
+ 2. Confirm with user before proceeding.
1284
+ 3. Run: \`elevasis-sdk creds delete {name} --force\`
1285
+
1286
+ **\`webhook-url\`:** Generate a webhook URL:
1287
+ Ask for provider, org UUID, resource ID, and credential name. Construct:
1288
+ \`POST https://api.elevasis.io/api/webhooks/{provider}?org={uuid}&resource={resourceId}&credential={credentialName}\`
1289
+
1290
+ **\`audit\`:** Scan project for credential references:
1291
+ 1. Search \`src/**/*.ts\` for \`credential:\` patterns and \`platform.getCredential()\` calls.
1292
+ 2. Extract all credential names referenced.
1293
+ 3. Run \`elevasis-sdk creds list\` to get the actual credential list.
1294
+ 4. Report: missing credentials (referenced but not created), unused credentials (created but not referenced).
1295
+
1296
+ ## Security Rules (MANDATORY)
1297
+
1298
+ - **NEVER** log, repeat, or display credential values after the user provides them
1299
+ - **NEVER** store credential values in files, memory, or command history
1300
+ - If an API call fails, ask the user to **re-paste** rather than retrying with a cached value
1301
+ - Always confirm name and type **before** asking for the value
1302
+ - OAuth credentials cannot be created via CLI -- redirect to Command Center UI
1303
+ `;
1304
+ }
1305
+ function claudeSdkPatternsRuleTemplate() {
1306
+ return `---
1307
+ description: Elevasis SDK patterns -- imports, source structure, runtime, and platform tools
1308
+ ---
1309
+
1310
+ # SDK Patterns
1311
+
1312
+ ## Imports
1313
+
1314
+ - \`@elevasis/sdk\` -- types and constants: \`WorkflowDefinition\`, \`StepType\`, \`ExecutionError\`, \`ToolingError\`
1315
+ - \`@elevasis/sdk/worker\` -- runtime: \`platform\`, \`PlatformToolError\`, typed adapters
1316
+ - **Never import from \`@repo/core\`** -- monorepo-internal, not available in external projects
1317
+
1318
+ ## Source Structure
1319
+
1320
+ - All resource definitions live in \`src/\` and are exported via \`src/index.ts\`
1321
+ - Organize by business domain: \`src/<domain>/\` (e.g., \`src/operations/\`, \`src/acquisition/\`)
1322
+ - Each domain barrel (\`src/<domain>/index.ts\`) exports \`workflows\` and \`agents\` arrays
1323
+ - Cross-domain utilities go in \`src/shared/\`; domain-specific utilities in \`src/<domain>/shared/\`
1324
+ - The default export in \`src/index.ts\` must be an \`OrganizationResources\` object
1325
+ - \`resourceId\` must be lowercase with hyphens, unique per organization
1326
+ - \`dist/\` is generated by deploy -- never commit it
1327
+
1328
+ ## Runtime
1329
+
1330
+ - \`.env\` contains only \`ELEVASIS_API_KEY\` for CLI auth -- never deployed, never in worker memory
1331
+ - Integration credentials are managed via the \`creds\` skill or Command Center UI
1332
+
1333
+ ## Platform Tools
1334
+
1335
+ Prefer typed adapters over raw \`platform.call()\`.
1336
+
1337
+ ### Singleton adapters (no credential needed)
1338
+
1339
+ \`\`\`typescript
1340
+ import { scheduler, storage, llm, notifications, lead, pdf, approval, execution, email } from '@elevasis/sdk/worker'
1341
+ \`\`\`
1342
+
1343
+ ### Factory adapters (credential-bound)
1344
+
1345
+ \`\`\`typescript
1346
+ import { createAttioAdapter, createResendAdapter } from '@elevasis/sdk/worker'
1347
+ const attio = createAttioAdapter('credential-name')
1348
+ \`\`\`
1349
+
1350
+ Use \`platform.call()\` directly only for tools without adapters: \`supabase\`, \`session-memory\`, \`hitl\`, \`status\`, \`http\`.
1351
+ `;
1352
+ }
1353
+ function claudeDocsAuthoringRuleTemplate() {
1354
+ return `---
1355
+ description: Documentation conventions for docs/ files -- MDX escaping, frontmatter, structure
1356
+ ---
1357
+
1358
+ # Docs Authoring
1359
+
1360
+ ## MDX Escaping
1361
+
1362
+ - Less-than \`<\` must be \`\\<\` (MDX interprets bare \`<\` as JSX tag)
1363
+ - Curly braces \`{var}\` must be in backticks or escaped: \`\\{var\\}\`
1364
+ - Greater-than \`>\` must be \`\\>\`
1365
+
1366
+ ## Frontmatter
1367
+
1368
+ Every \`.mdx\` file requires \`title\` and \`description\`:
1369
+
1370
+ \`\`\`yaml
1371
+ ---
1372
+ title: Feature Name
1373
+ description: Concise description
1374
+ ---
1375
+ \`\`\`
1376
+
1377
+ ## Structure
1378
+
1379
+ - \`docs/project-map.mdx\` is auto-generated -- do not edit manually
1380
+ - \`docs/in-progress/\` for task tracking docs
1381
+ - Sort order via \`order\` frontmatter field (lower = earlier)
1382
+ `;
1383
+ }
1384
+ function claudeMemoryConventionsRuleTemplate() {
1385
+ return `---
1386
+ description: Memory system conventions -- what to store, structure, pruning
1387
+ ---
1388
+
1389
+ # Memory Conventions
1390
+
1391
+ ## What Memory Is
1392
+
1393
+ Memory stores persistent agent state: skills, errors, tutorial progress.
1394
+ It is NOT for instructions (commands), reference docs, or templates.
1395
+
1396
+ ## Structure
1397
+
1398
+ - \`index.md\` at every level maps to children
1399
+ - Start at root index and drill down
1400
+ - When a file outgrows a single document, split into a subdirectory
1401
+
1402
+ ## Pruning
1403
+
1404
+ - Keep ~20 recent entries per table; drop stale patterns (30+ days)
1405
+ - If an error recurs 3+ times, promote to \`.claude/rules/workspace-patterns.md\`
1406
+ `;
1407
+ }
1408
+ function claudeProjectMapRuleTemplate() {
1409
+ return `---
1410
+ description: Project map conventions -- auto-generated, do not edit, maintained by deploy and /meta fix
1411
+ ---
1412
+
1413
+ # Project Map
1414
+
1415
+ - \`docs/project-map.mdx\` and \`docs/resource-map.mdx\` are fully auto-generated by \`elevasis deploy\`
1416
+ - Do not edit either file manually -- changes are overwritten on next deploy
1417
+ - \`/meta fix\` step 8 checks for drift and patches the map
1418
+ - If a new command, rule, skill, or memory file is added, run \`/meta fix\` or \`elevasis deploy\` to update
1419
+ `;
1420
+ }
1421
+ function claudeTaskTrackingRuleTemplate() {
1422
+ return `---
1423
+ description: In-progress task conventions -- /work command, doc format, status values, auto-save behavior
1424
+ ---
1425
+
1426
+ # Task Tracking
1427
+
1428
+ ## Status Values
1429
+
1430
+ Exactly three values for frontmatter \`status\`: \`planned\`, \`in-progress\`, \`complete\`.
1431
+
1432
+ ## Doc Format
1433
+
1434
+ - Frontmatter: \`title\`, \`description\`, \`status\`
1435
+ - Sections: Objective, Plan, Progress, Resume Context
1436
+ - Progress subsections use markers: \`### Step N: Title -- PENDING\`, \`-- IN PROGRESS\`, \`-- COMPLETE\`
1437
+
1438
+ ## Auto-Update Behavior
1439
+
1440
+ - When working on a tracked task, update the Progress section when a plan step transitions:
1441
+ - PENDING -> IN PROGRESS (starting work on a step)
1442
+ - IN PROGRESS -> COMPLETE (finishing a step)
1443
+ - Do NOT update on every action -- only on step transitions
1444
+
1445
+ ## Save Suggestions
1446
+
1447
+ Proactively suggest \`/work save\` when:
1448
+ - The conversation context is getting heavy (many tool calls, large file reads)
1449
+ - The user appears to be wrapping up (thanks, goodbye, switching topics)
1450
+ - Significant progress has been made (2+ steps completed without saving)
1451
+ - Before a \`/clear\` or context reset
1452
+
1453
+ ## Completion Suggestions
1454
+
1455
+ When all plan steps are marked COMPLETE, suggest \`/work complete\` to finalize the task.
1456
+
1457
+ ## Directory Conventions
1458
+
1459
+ - \`docs/in-progress/\` for all active task docs
1460
+ - Small tasks: \`<slug>.mdx\` directly in \`docs/in-progress/\`
1461
+ - Multi-file tasks: \`<slug>/index.mdx\` with supporting docs alongside
1462
+ - Completed tasks move OUT of \`docs/in-progress/\` to \`docs/<relevant-dir>/\`
1463
+ `;
1464
+ }
455
1465
 
456
1466
  // src/cli/commands/templates/core/resources.ts
457
1467
  function starterWorkflowTemplate() {
@@ -600,4 +1610,24 @@ export const agents = []
600
1610
  `;
601
1611
  }
602
1612
 
603
- export { claudeDocsCommandTemplate, claudeMdTemplate, claudeMetaCommandTemplate, claudeSettingsTemplate, claudeTutorialCommandTemplate, exampleBarrelTemplate, gitignoreTemplate, operationsBarrelTemplate, platformStatusTemplate, starterWorkflowTemplate };
1613
+ // src/cli/commands/templates/core/index.ts
1614
+ function getManagedTemplates(ctx = {}) {
1615
+ return {
1616
+ "elevasis.config.ts": configTemplate,
1617
+ ".gitignore": () => gitignoreTemplate(ctx),
1618
+ "CLAUDE.md": () => claudeMdTemplate(ctx),
1619
+ ".claude/settings.json": claudeSettingsTemplate,
1620
+ ".claude/hooks/enforce-sdk-boundary.mjs": claudeSdkBoundaryHookTemplate,
1621
+ ".claude/commands/tutorial.md": claudeTutorialCommandTemplate,
1622
+ ".claude/commands/meta.md": claudeMetaCommandTemplate,
1623
+ ".claude/commands/work.md": claudeWorkCommandTemplate,
1624
+ ".claude/skills/creds/SKILL.md": claudeCredsSkillTemplate,
1625
+ ".claude/rules/sdk-patterns.md": claudeSdkPatternsRuleTemplate,
1626
+ ".claude/rules/docs-authoring.md": claudeDocsAuthoringRuleTemplate,
1627
+ ".claude/rules/memory-conventions.md": claudeMemoryConventionsRuleTemplate,
1628
+ ".claude/rules/project-map.md": claudeProjectMapRuleTemplate,
1629
+ ".claude/rules/task-tracking.md": claudeTaskTrackingRuleTemplate
1630
+ };
1631
+ }
1632
+
1633
+ export { claudeCredsSkillTemplate, claudeDocsAuthoringRuleTemplate, claudeMdTemplate, claudeMemoryConventionsRuleTemplate, claudeMetaCommandTemplate, claudeProjectMapRuleTemplate, claudeSdkBoundaryHookTemplate, claudeSdkPatternsRuleTemplate, claudeSettingsTemplate, claudeTaskTrackingRuleTemplate, claudeTutorialCommandTemplate, claudeWorkCommandTemplate, exampleBarrelTemplate, getManagedTemplates, gitignoreTemplate, operationsBarrelTemplate, platformStatusTemplate, starterWorkflowTemplate };